Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 879183 - dev-lang/nim-1.6.8 does not work in EPREFIX (searches for its standard library in wrong location)
Summary: dev-lang/nim-1.6.8 does not work in EPREFIX (searches for its standard librar...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Nim project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-02 15:02 UTC by Michael Schubert
Modified: 2023-03-11 17:44 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge_info.txt,6.02 KB, text/plain)
2022-11-03 10:14 UTC, Michael Schubert
Details
emerge -pvO dev-lang/nim (emerge_nim.txt,193 bytes, text/plain)
2022-11-03 10:15 UTC, Michael Schubert
Details
nim.cfg (nim.cfg,10.81 KB, text/plain)
2022-11-03 10:16 UTC, Michael Schubert
Details
config.nims (config.nims,896 bytes, text/plain)
2022-11-03 10:17 UTC, Michael Schubert
Details
strace nim dump > nim_strace.txt 2>&1 (nim_strace.txt,20.20 KB, text/plain)
2022-11-03 16:00 UTC, Michael Schubert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Schubert 2022-11-02 15:02:00 UTC
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?
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-11-03 01:31:17 UTC
(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.
Comment 2 Maciej Barć gentoo-dev 2022-11-03 02:04:15 UTC
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]
"""
Comment 3 Anna Vyalkova 2022-11-03 02:09:52 UTC
> # Error: cannot open '${EPREFIX}/usr/lib/system.nim'

Do you really get literal non-expanded $EPREFIX?
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-11-03 02:28:20 UTC
Please share emerge --info & emerge -pvO dev-lang/nim.
Comment 5 Michael Schubert 2022-11-03 10:14:43 UTC
Created attachment 826857 [details]
emerge --info

emerge --info
Comment 6 Michael Schubert 2022-11-03 10:15:18 UTC
Created attachment 826859 [details]
emerge -pvO dev-lang/nim
Comment 7 Michael Schubert 2022-11-03 10:16:39 UTC
Created attachment 826861 [details]
nim.cfg
Comment 8 Michael Schubert 2022-11-03 10:17:45 UTC
Created attachment 826863 [details]
config.nims
Comment 9 Maciej Barć gentoo-dev 2022-11-03 10:21:30 UTC
> SHELL="/home/m.schubert/gentoo/bin/fish"

Does it work under bash?
Comment 10 Michael Schubert 2022-11-03 10:25:37 UTC
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'
Comment 11 Maciej Barć gentoo-dev 2022-11-03 10:27:28 UTC
> I get my $EPREFIX directory (~/gentoo/), not the variable literal. Sorry if this was confusing.

OH! This was VERY confusing.
Comment 12 Maciej Barć gentoo-dev 2022-11-03 10:28:57 UTC
So turns out that "$lib" from nim variables like 

> path="$lib/deprecated/core"

does not expand properly inside prefixed systems.
Comment 13 Maciej Barć gentoo-dev 2022-11-03 10:41:10 UTC
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.
Comment 14 Maciej Barć gentoo-dev 2022-11-03 10:45:27 UTC
I think adding

> lib %= "$EPREFIX/usr/lib/nim"

inside /etc/nim/nim.cfg might be a more worthwhile solution.

WDYT Anna?
Comment 15 Anna Vyalkova 2022-11-03 11:12:37 UTC
> 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.
Comment 16 Michael Schubert 2022-11-03 14:57:19 UTC
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
Comment 17 Maciej Barć gentoo-dev 2022-11-03 15:00:29 UTC
(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?
Comment 18 Michael Schubert 2022-11-03 15:05:37 UTC
$>  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'
Comment 19 Maciej Barć gentoo-dev 2022-11-03 15:11:14 UTC
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.
Comment 20 Maciej Barć gentoo-dev 2022-11-03 15:15:46 UTC
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)?
Comment 21 Michael Schubert 2022-11-03 15:19:39 UTC
$> 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/
Comment 22 Maciej Barć gentoo-dev 2022-11-03 15:23:43 UTC
(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: ?
Comment 23 Michael Schubert 2022-11-03 15:25:44 UTC
--lib works as expected; sorry, I know nothing about nim
Comment 24 Maciej Barć gentoo-dev 2022-11-03 15:44:07 UTC
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)?
Comment 25 Michael Schubert 2022-11-03 16:00:06 UTC
Created attachment 826885 [details]
strace nim dump > nim_strace.txt 2>&1
Comment 26 Maciej Barć gentoo-dev 2022-11-03 16:03:33 UTC
> 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.