Module path lookup isn't robust enough for NixOS and some "portable" setups (Bug #872)
Description
Hello Alexis,
AMC on NixOS behaves like a "portable" distribution, where the whole package (including libs, docs, and so on) is stored isolated in a single directory (this is how Nix/NixOS works: there is no global state, no globally shared modules, but a "store" of packages and a ton of symlinks and env variables to bring all that together).
This causes an issue: if for some reason, the system on which AMC runs has a /lib
directory, AMC will try to load its modules there, and fail. Changing the MODSDIR
variable at compilation doesn't help, because it also changes the installation directory's name, but AFAICT the main executable hardcodes the lib
name:
51 $mods_dir=catfile($base_dir,'lib');
Idk enough Perl to offer a patch, but a simple fix could be to improve the test at line 44:
44 if(! -d $mods_dir) {
By checking for the full path of, say, AMC-gui.pl
, so $MODSDIR/perl/AMC-gui.pl
Thanks!
Best regards,
Thibault
History
Updated by Alexis Bienvenüe 12 days ago
Comming back to this topic very late: is it still relevant?
Updated by Michal Sojka 10 days ago
Yes and no. We currently use a workaround, which works, but looks ugly and fragile. Basically, we have to set all *DIR
variables to absolute path and unset DESTDIR
. See https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/au/auto-multiple-choice/package.nix#L38-L66. If there is a simpler way, such as setting a single variable, e.g., PREFIX
, we would appreciate it.
Updated by Alexis Bienvenüe 10 days ago
a simple fix could be to improve the test at line 44:
44 if(! -d $mods_dir) {
By checking for the full path of, say, AMC-gui.pl, so $MODSDIR/perl/AMC-gui.pl
I'd say this doesn't have any drawback. Would it be OK for NixOS?
Updated by Alexis Bienvenüe 8 days ago
Since git:0e884e2a64935f334b, the "portable" block in auto-multiple-choice
is only evaluated for the portable distribution (built with make portable
from the source tree).