ugexe / zef

Raku Module Management
Artistic License 2.0
206 stars 44 forks source link

zef installs some module resources to /tmp/.zef which are missing on reboot #546

Closed avuserow closed 7 months ago

avuserow commented 7 months ago

zef install Crypt::Argon2 installs the resources (such as its .so file) to /tmp. Since /tmp is tmpfs on many Linux distros (including Fedora), this is removed upon a reboot, and results in errors such as

Cannot locate native library '/tmp/.zef/1703642021.119893/1703642022.119893.237.1946489885046/resources/34941271E1DC62CAA3FE862F03D60D58AB930360.so': /tmp/.zef/1703642021.119893/1703642022.119893.237.1946489885046/resources/34941271E1DC62CAA3FE862F03D60D58AB930360.so: cannot open shared object file: No such file or directory

Context

I have not tested this with many modules. I know that Crypt::Argon2 is affected and my own Audio::TagLib is not, despite both creating .so files. Argon2 uses LibraryMake while TagLib does not so that may be a potential difference. The variables in Build.pm for Crypt::Argon2 look fine so it may be something within LibraryMake.

I was able to determine that d88d0ea5f118780f6ffcdee6690d7776e2b3aaa6 is the first bad commit with git bisect.

Expected Behavior

Module resources should be installed to something like <SOME_PREFIX>/install/share/perl6/site/resources

Actual Behavior

Module dependencies are installed in /tmp/.zef

Steps to Reproduce

zef install Crypt::Argon2
rm -rf /tmp/.zef # simulate clearing tmpfs
# try to use it:
raku -e'use Crypt::Argon2::DeriveKey; say argon2-derive-key("something", :hashlen(16))'

Your Environment

Even though zef 19.1 is installed, I noticed this with the latest zef. If you need any help, feel free to ping me on discord if I don't respond quickly here.

ugexe commented 7 months ago

Are you sure those files aren't actually installed in the expected location, and that your code isn't using a precompiled string pointing to /tmp/whatever (the temporary location modules are installed to before actually being moved to the expected install location)?

ugexe commented 7 months ago

Yeah, I think https://github.com/skinkade/p6-crypt-argon2/blob/70b041bdf7ac6d68e7c010d3581e075f9a704d4c/lib/Crypt/Argon2/Base.pm6#L9C1-L9C53 is incorrect (it should not be calling .Str on %?RESOURCES) and should be just constant ARGON2 = %?RESOURCES<libraries/argon2>

ugexe commented 7 months ago

I wonder if it would be worth opening an issue or a PR on rakudo to deprecate calling .Str on a Distribution::Resources object... @niner thoughts?

niner commented 7 months ago

Yeah, this is a recurring issue. Don't know why people insist on stringifying those paths.

avuserow commented 7 months ago

Thanks for the help debugging. I filed a PR for Crypt::Argon2 and verified that it works now.