Nim: koch boot fails if even an empty config.nims is present in ~/.config/nims/ [devel regression]

Created on 12 Mar 2020  路  5Comments  路  Source: nim-lang/Nim

Building nim devel using koch boot fails after https://github.com/nim-lang/Nim/commit/6b3098c378430e3387854ffc413ce96bd94a3d2c if ~/.config/nim/config.nims file is present, even an empty one.

Example

Build Nim devel as usual. At one point you will reach ./koch boot -d:release.

Current Output

bin/nim jsonscript -d:release --nimcache:nimcache/r_linux_amd64 compiler/nim.nim
Hint: used config file '/home/kmodi/downloads/git/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/kmodi/downloads/git/Nim/config/config.nims' [Conf]
Hint: used config file '/home/kmodi/.config/nim/config.nims' [Conf]
Hint: used config file '/home/kmodi/downloads/git/Nim/compiler/nim.cfg' [Conf]

caught exception:n/home/kmodi/downloads/git/Nim/nimcache/r_linux_amd64/nim.json(2, 1) Error: { expected
stacktrace:
parsejson.nim(522)       raiseParseErr
error evaluating JSON file: /home/kmodi/downloads/git/Nim/nimcache/r_linux_amd64/nim.json
FAILURE

The /home/${USER}/downloads/git/Nim/nimcache/r_linux_amd64/nim.json in the error message is indeed a corrupts JSON.. here are the first few lines from that file:

{"compile":[
,
["/home/kmodi/downloads/git/Nim/nimcache/r_linux_amd64/stdlib_io.nim.c", "gcc -c  -w -O3 -fno-strict-aliasing -fno-ident  -I/home/kmodi/downloads/git/Nim/lib -I/home/kmodi/downloads/git/Nim/compiler -o /home/kmodi/downloads/git/Nim/nimcache/r_linux_amd64/stdlib_io.nim.c.o /home/kmodi/downloads/git/Nim/nimcache/r_linux_amd64/stdlib_io.nim.c"],

Expected Output

nim should build just fine.

If I look at that same nim.json after a successful build, it does not have that lonely comma in the first line..

{"compile":[
["/home/kmodi/downloads/git/Nim/nimcache/r_linux_amd64/stdlib_assertions.nim.c", "gcc -c  -w -O3 -fno-strict-aliasing -fno-ident  -I/home/kmodi/downloads/git/Nim/lib -I/home/kmodi/downloads/git/Nim/compiler -o /home/kmodi/downloads/git/Nim/nimcache/r_linux_amd64/stdlib_assertions.nim.c.o /home/kmodi/downloads/git/Nim/nimcache/r_linux_amd64/stdlib_assertions.nim.c"],

Additional Information

  • This regression happened after https://github.com/nim-lang/Nim/commit/6b3098c378430e3387854ffc413ce96bd94a3d2c
  • If I revert that commit or check out the commit prior to that commit ( i.e. https://github.com/nim-lang/Nim/commit/70bd41dae08a7ba9a9e8f19a935bee26b689d00d ), the build finishes fine. Note: when trying to reproduce this issue, remember to rm -f the nimcache dir in the Nim build area each time to prevent Nim from parsing the older nim.json.
  • If I delete the ~/.config/nim/config.nims, the build finishes fine.
  • OS: 64-bit Linux -- RHEL 6.8

/cc @Clyybber

Most helpful comment

image

All 5 comments

@Clyybber and @timotheecour Thanks for working together to fix this.

Though, why wasn't this issue caught on CI? Can a test config.nims be added (I thought there was one already) to the Nim repo that can catch issues like this?

It actually wasn't caught because it requires doing ./koch boot twice afaict. (once to build the broken binary, and another time to use it to do koch boot)

Hmm, then the config.nims was a red herring here? I must have moved and restored my config.nims at least 3 times to check that the existence of config.nims indeed caused the issue. I'll check this bug's fix later today. Thanks.

Yeah, it was a red herring I think

image

Was this page helpful?
0 / 5 - 0 ratings