After installing the current =dev-lang/nim-1.6.8, compilation of a (non-existant) file fails with the following error: > nim c test.nim # Error: cannot open '${EPREFIX}/usr/lib/system.nim' The requested file is present in usr/lib/nim instead of usr/lib. Shouldn't this work out of the box?
(In reply to Michael Schubert from comment #0) > After installing the current =dev-lang/nim-1.6.8, compilation of a > (non-existant) file fails with the following error: > > > nim c test.nim > # Error: cannot open '${EPREFIX}/usr/lib/system.nim' > > The requested file is present in usr/lib/nim instead of usr/lib. > Yeah, icky indeed. > Shouldn't this work out of the box? I dare say that part is obvious and could be appended to the end of many a bug report.
Michael, could you share the test program if it exists? > compilation of a (non-existant) Very weird, it does not output that error for nonexistent (source) files on my system with both USE=experimental and without. Could you also share the two nim system config files, that is: - /etc/nim/nim.cfg - /etc/nim/config.nims Please also compile this program if you can, file "system_test.nim": """ assert 0b0001_0000'i8 shr 2 == 0b0000_0100'i8 """ for me it outputs: """ Hint: used config file '/etc/nim/nim.cfg' [Conf] Hint: used config file '/etc/nim/config.nims' [Conf] ......................................................... CC: ../../usr/lib/nim/std/private/digitsutils.nim CC: ../../usr/lib/nim/system/assertions.nim CC: ../../usr/lib/nim/system/dollars.nim CC: ../../usr/lib/nim/system.nim CC: system_test.nim Hint: [Link] Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code) 26691 lines; 0.603s; 31.582MiB peakmem; proj: /tmp/tmp.6QbnxcvstM/system_test.nim; out: /tmp/tmp.6QbnxcvstM/system_test [SuccessX] """
> # Error: cannot open '${EPREFIX}/usr/lib/system.nim' Do you really get literal non-expanded $EPREFIX?
Please share emerge --info & emerge -pvO dev-lang/nim.
Created attachment 826857 [details] emerge --info emerge --info
Created attachment 826859 [details] emerge -pvO dev-lang/nim
Created attachment 826861 [details] nim.cfg
Created attachment 826863 [details] config.nims
> SHELL="/home/m.schubert/gentoo/bin/fish" Does it work under bash?
I attached all additional requested files. > Michael, could you share the test program if it exists? It's an invalid path, but the same happens for valid files. > Please also compile this program if you can, file "system_test.nim" I get the same error: $> nim c system_test.nim Error: cannot open '/home/m.schubert/gentoo/usr/lib/system.nim' > Do you really get literal non-expanded $EPREFIX? I get my $EPREFIX directory (~/gentoo/), not the variable literal. Sorry if this was confusing. > Does it work under bash? $> bash -c 'nim c system_test.nim' Error: cannot open '/home/m.schubert/gentoo/usr/lib/system.nim'
> I get my $EPREFIX directory (~/gentoo/), not the variable literal. Sorry if this was confusing. OH! This was VERY confusing.
So turns out that "$lib" from nim variables like > path="$lib/deprecated/core" does not expand properly inside prefixed systems.
As a temporal workaround you can set "lib" to "/home/m.schubert/gentoo/usr/lib/nim" (before "path") inside the "/etc/nim/nim.cfg" file.
I think adding > lib %= "$EPREFIX/usr/lib/nim" inside /etc/nim/nim.cfg might be a more worthwhile solution. WDYT Anna?
> lib %= "$EPREFIX/usr/lib/nim" It should be evaluated build-time, of course.. The file is "config/nim.cfg" in sources, it's installed as-is.
I'm still getting the same error if I add > lib %= "$EPREFIX/usr/lib/nim" before the first path= in etc/nim/nim.cfg, also with adding the $EPREFIX value instead of the variable
(In reply to Michael Schubert from comment #16) > I'm still getting the same error if I add > > > lib %= "$EPREFIX/usr/lib/nim" > > before the first path= in etc/nim/nim.cfg, also with adding the $EPREFIX > value instead of the variable Are you sure? If You do > lib = "/home/m.schubert/gentoo/usr/lib/nim" it does NOT work?
$> diff -Nau etc/nim/nim.cfg{.orig,} ``` --- etc/nim/nim.cfg.orig 2022-11-03 15:02:35.517920385 -0000 +++ etc/nim/nim.cfg 2022-11-03 15:01:41.677754001 -0000 @@ -27,6 +27,7 @@ mips.linux.gcc.exe = "mips-openwrt-linux-gcc" mips.linux.gcc.linkerexe = "mips-openwrt-linux-gcc" +lib = "/home/m.schubert/gentoo/usr/lib/nim" path="$lib/deprecated/core" path="$lib/deprecated/pure" path="$lib/pure/collections" ``` $> nim c xsystem_test.nim Error: cannot open '/home/m.schubert/gentoo/usr/lib/system.nim'
If I set it to a nonexistent path on my system I get > Error: cannot open '/home/m.schubert/gentoo/usr/lib/nim/system.nim' So nim removed the "nim" dir form the path on your system.
Maybe nim always looks for config at root!? That's why the config was not picked up on your OS. Could you try to set in on your host system (outside prefix)?
$> nim --path:/home/m.schubert/gentoo/usr/lib/nim/ c system_test.nim should always work, right? I still see the same error, also if I set an invalid dir in either the config or the argument: > Error: cannot open '/home/m.schubert/gentoo/usr/lib/system.nim' I unfortunately can't write on the host outside my user. The only way I can get a different error is to copy system.nim to gentoo/usr/lib/
(In reply to Michael Schubert from comment #21) > $> nim --path:/home/m.schubert/gentoo/usr/lib/nim/ c system_test.nim > > should always work, right? I still see the same error, also if I set an > invalid dir in either the config or the argument: And with --lib: instead of --path: ?
--lib works as expected; sorry, I know nothing about nim
So looks like the only workaround for EPREFIX users is to always pass --lib:... option to the nim transpiler. Michael, can you post output of "strace nim dump 2>&1" (so we can see what config files nim tries to open)?
Created attachment 826885 [details] strace nim dump > nim_strace.txt 2>&1
> openat(AT_FDCWD, "/etc/nim/nim.cfg", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) > openat(AT_FDCWD, "/home/m.schubert/.config/nim/nim.cfg", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) > openat(AT_FDCWD, "/nim.cfg", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) > openat(AT_FDCWD, "/home/nim.cfg", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) > openat(AT_FDCWD, "/home/m.schubert/nim.cfg", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) So as I suspected nim only looks at real root, but you can try copying the file from ${EPREFIX}/etc/nim/nim.cfg to /home/m.schubert/.config/nim/nim.cfg and setting the "lib" variable there.