Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

om init may not preserve file permissions when instantiating templates #429

Closed
cameronraysmith opened this issue Feb 28, 2025 · 3 comments · Fixed by #434
Closed

om init may not preserve file permissions when instantiating templates #429

cameronraysmith opened this issue Feb 28, 2025 · 3 comments · Fixed by #434
Labels
bug Something isn't working

Comments

@cameronraysmith
Copy link

cameronraysmith commented Feb 28, 2025

Briefly, direnv fails after instantiating a template with om init because the template relies on an executable script and the template instantiation doesn't seem to preserve the permissions of the files from the template.

Git-tracked file permissions are not preserved on template instantiation

Steps to reproduce:

Clone the git repo and check script file permissions

❯ git clone https://github.com/sciexp/python-nix-template test-pnt
❯ cd test-pnt
❯ git checkout 7d17d0dbffe756f1804aa86fe95bf61a1867d4d3
❯ ls -alh ./scripts
.rwxr-xr-x user group 838 B Fri Feb 28 22:51:50 2025  set-git-env.sh
❯ stat -c "%a %n" scripts/set-git-env.sh
755 scripts/set-git-env.sh

Use om init to instantiate the template and check file permissions

❯ om init github:sciexp/python-nix-template/7d17d0dbffe756f1804aa86fe95bf61a1867d4d3 -o test-om-pnt
❯ ls -alh test-om-pnt/scripts
.rw-r--r-- user group 838 B Wed Dec 31 19:00:01 1969  set-git-env.sh
❯ stat -c "%a %n" test-om-pnt/scripts/set-git-env.sh
644 scripts/set-git-env.sh

The modification date for scripts/set-git-env.sh has been set to the Unix epoch and the permissions have been changed from 755 to 644.

See ASCII cast from #425 and discussion in #424, #424 (comment) for additional context.

@srid
Copy link
Member

srid commented Mar 9, 2025

The modification date for scripts/set-git-env.sh has been set to the Unix epoch and the permissions have been changed from 755 to 644.

Looks like the problem is here

fs::copy(path, &target).await?;
fs::set_permissions(&target, Permissions::from_mode(0o644)).await?;

@srid
Copy link
Member

srid commented Mar 9, 2025

With #434,

Image

@srid srid closed this as completed in #434 Mar 9, 2025
@srid srid closed this as completed in 460d79c Mar 9, 2025
@cameronraysmith
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants