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.
Build Nim devel as usual. At one point you will reach ./koch boot -d:release.
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"],
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"],
rm -f the nimcache dir in the Nim build area each time to prevent Nim from parsing the older nim.json. ~/.config/nim/config.nims, the build finishes fine./cc @Clyybber
@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

Most helpful comment