Skip to content

Fix permissions on keccak.md #785

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

Merged
merged 5 commits into from
Aug 23, 2024
Merged

Fix permissions on keccak.md #785

merged 5 commits into from
Aug 23, 2024

Conversation

palinatolmach
Copy link
Collaborator

@palinatolmach palinatolmach commented Aug 23, 2024

Fixes an issue introduced in #779 by making out/kompiled/requires/keccak.md (and any other filed copied to requires in future) writeable for the current user, group, and others (anyone with access to the file).

The files have to writeable so they can be deleted and replaced when kontrol build --rekompile is executed. The files not copied from kontrol/kdist had write access previously, but the ones we are now copying from kdist (such as keccak.md) don't, which causes issues such as this one:

INFO 2024-08-23 08:58:19,927 kontrol.kompile - Copying requires path: /nix/store/g67pca4v4lx9zgna190kdwvrj4n0jarm-python3.10-kontrol-0.1.409/lib/python3.10/site-packages/kontrol/kdist/keccak.md ->                           
out/kompiled/requires/keccak.md                                                                                                                                                                                                
An error occurred while building your Kontrol project: [Errno 13] Permission denied: 'out/kompiled/requires/keccak.md'

@palinatolmach palinatolmach marked this pull request as ready for review August 23, 2024 09:27
@tothtamas28
Copy link
Contributor

Btw, is it possible the root of the issue is that these files have not been checked in to source control with the right permission?

@palinatolmach
Copy link
Collaborator Author

@tothtamas28 it would probably help, but these files are part of the kompilation artifacts usually placed in the /out folder in Foundry projects, and it's usually not tracked by source control at all (here's one example from a project we're looking at).

@tothtamas28
Copy link
Contributor

tothtamas28 commented Aug 23, 2024

these files are part of the kompilation artifacts usually placed in the /out folder in Foundry projects

What I'm wondering, if the template of these files (i.e. in the KSRC_DIR) have the correct permissions, and shutil.copy preserves file permissions, why do the files placed in out have the wrong permissions.

@palinatolmach
Copy link
Collaborator Author

What I'm wondering, if the template of these files (i.e. in the KSRC_DIR) have the correct permissions, and shutil,copy preserves file permissions, why do the files placed in out have the wrong permissions.

Ah, got it, thanks, it looks like they don't.

If kontrol build is run from a local checkout (poetry run kontrol build), then these files are copied with write permissions as they are in src/kontrol/kdist:

❯ ls -l src/kontrol/kdist
total 304
-rw-r--r--  1 palina  staff      0 Apr  9 20:53 __init__.py
drwxr-xr-x  5 palina  staff    160 Apr 11 16:36 __pycache__
-rw-r--r--  1 palina  staff  19147 Aug  9 15:15 assert.md
...
-rw-r--r--@ 1 palina  staff   3218 Aug 22 22:15 keccak.md

If we run kontrol build using a kup installation, then they're copied from something like /nix/store/gyx8hr1kq30chx12bdziqv5yyz582ql3-python3.10-kontrol-0.1.409/lib/python3.10/site-packages/kontrol/kdist/, and the kdist files only have read permissions there:

> ls -l /nix/store/gyx8hr1kq30chx12bdziqv5yyz582ql3-python3.10-kontrol-0.1.409/lib/python3.10/site-packages/kontrol/kdist/
-r--r--r--@ 1 root  wheel      0 Jan  1  1970 __init__.py
dr-xr-xr-x@ 8 root  wheel    256 Jan  1  1970 __pycache__
-r--r--r--@ 1 root  wheel  19147 Jan  1  1970 assert.md
...
-r--r--r--@ 1 root  wheel   3218 Jan  1  1970 keccak.md

In short, it seems that the kdist files distributed with kup-installed Kontrol are read-only, and I thought it's intentional.

@tothtamas28
Copy link
Contributor

In short, it seems that the kdist files distributed with kup-installed Kontrol are read-only, and I thought it's intentional.

Makes sense, thank you for debugging this. The Nix store in general is read only, so your fix is indeed the right thing to do.

@palinatolmach
Copy link
Collaborator Author

@tothtamas28 thanks for your help!

@anvacaru anvacaru merged commit 8024ea8 into master Aug 23, 2024
12 checks passed
@anvacaru anvacaru deleted the fix-keccak-permission branch August 23, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants