dom96 / choosenim

Tool for easily installing and managing multiple versions of the Nim programming language.
BSD 3-Clause "New" or "Revised" License
681 stars 65 forks source link

`Error: Spawning of process failed` caused by choosenim using a wrapper process (shim) instead of symbolic link #126

Open timotheecour opened 5 years ago

timotheecour commented 5 years ago

choosenim is implemented by a binary that dispatches to the real nim binary; this prevents using lldb -- nim c -r foo, at least on OSX:

I'm curious why isn't choosenim using symbolic links (at least on posix) which seems a simpler approach and avoids this kind of problem ? maybe I'm missing something?

# main.nim ($timn_D/tests/nim/all/t0496.nim)
echo "ok1"
nim c -r main.nim
works
lldb -o run -- /pathto/Nim/nim c -r main.nim
works
choosenim /pathto/Nim/
which nim
/Users/timothee/.nimble//bin/nim

lldb -o run -- nim c -r main.nim
Error: Spawning of process failed. (Error was: Interrupted system call)

i'm on OSX (where gdb isn't supported, only lldb)

nim --version
Nim Compiler Version 0.20.99 [MacOSX: amd64]
Compiled at 2019-07-10
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: cb3c3c306c6507a09c15da26828a39fbbd4dbc66
active boot switches: -d:release

but this bug has always been there

EDIT: related to https://github.com/nim-lang/Nim/issues/9634; I may have a patch but no PR yet; but still genuinely curious why can't symbolic links be used instead, on posix?

dom96 commented 5 years ago

IIRC the main reason I chose to do it this way is simplicity, supporting both symlinks and this proxy exe would have been more complex.

To be honest I think the underlying bug should be fixed, even if choosenim uses symlinks it won't fix this problem.

timotheecour commented 4 years ago

windows can use symlinks too, eg https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

timotheecour commented 4 years ago

hopefully fixed by https://github.com/nim-lang/Nim/pull/13232 but still, symlinks should be used IMO

timotheecour commented 3 years ago

actually, this is not fixed, shim/wrapper process causes the following issue:

lldb -o r -o quit /Users/timothee/.nimble//bin/nim

 Error: Spawning of process failed. (Error was: Interrupted system call)
  Info: If unexpected, please report this error to https://github.com/dom96/choosenim

Process 59025 exited with status = 1 (0x00000001)

dom96 commented 3 years ago

Is this with latest version of choosenim? Can you reproduce it? Does it happen with older versions too?

timotheecour commented 3 years ago

thanks for re-opening, see also https://github.com/nim-lang/Nim/issues/16838 which lists several issues caused by shims instead of symlinks (including one that prevents using testament in nimble tests), and was closed as This is not a Nim issue but a choosenim issue.

This is an important issue that should be tracked and eventually fixed.

Is this with latest version of choosenim?

yes. choose -v choosenim v0.7.4 (2020-10-20 17:23:03) [macosx/amd64]

Can you reproduce it?

yes, i retried with latest choosenim (0.7.4) and it results in same error as https://github.com/dom96/choosenim/issues/126#issuecomment-767959944 for any shim generated by choosenim / proxyexe.

Does it happen with older versions too?

how do I build a shim?

git clone https://github.com/dom96/choosenim && cd choosenim
nim c -o:/tmp/z01 src/choosenimpkg/proxyexe.nim

fails with: cliparams.nim(179, 7) Error: undeclared identifier: 'setNimbleDir' and setNimbleDir isn't defined in this repo.

dom96 commented 3 years ago

how do I build a shim?

Can you just grab the choosenim release from the releases page and use it to install Nim somewhere? You can set a new $HOME or whatever to not overwrite your existing install.

timotheecour commented 3 years ago

0.3.0

HOME=/tmp/d09c /Users/timothee/Downloads/choosenim-0.3.0_macosx_amd64 1.4.2

lldb -o r -o quit /tmp/d09c/.nimble/bin/nim

     Error: Traceback (most recent call last)
        ... proxyexe.nim(62)         proxyexe
        ... proxyexe.nim(53)         main
        ... Spawning of process failed. (Error was: Interrupted system call)
      Info: If unexpected, please report this error to https://github.com/dom96/choosenim
Process 57390 exited with status = 1 (0x00000001)

0.7.5

HOME=/tmp/d09b /Users/timothee/Downloads/choosenim-0.7.5-20210102-f338473_macosx_amd64 1.4.2 lldb -o r -o quit /tmp/d09b/.nimble/bin/nim Error: Spawning of process failed. (Error was: Interrupted system call) Info: If unexpected, please report this error to https://github.com/dom96/choosenim Process 49248 exited with status = 1 (0x00000001)

build from source on latest choosenim master

git rev-parse HEAD f338473dd7557a9fda5276f30aafa76ced5ed85d NIMBLE_DIR=$HOME/.nimble_fake50 nimble install HOME=/tmp/d09 bin/choosenim 1.4.2 lldb -o r -o quit /tmp/d09/.nimble/bin/nim

 Error: Spawning of process failed. (Error was: Interrupted system call)
  Info: If unexpected, please report this error to https://github.com/dom96/choosenim
timotheecour commented 3 years ago

minimized repro:

import osproc
proc main()=
  let exePath = "/Users/timothee/git_clone/nim/Nim_devel/bin/nim"
  let p = startProcess(exePath, options={poParentStreams})
  let exitCode = p.waitForExit()
  p.close()
main()

nim c -o:/tmp/z01 main lldb -o r -o quit /tmp/z01

/Users/timothee/git_clone/nim/timn/tests/nim/all/t11753.nim(14) t11753 /Users/timothee/git_clone/nim/timn/tests/nim/all/t11753.nim(11) main /Users/timothee/git_clone/nim/Nim_devel/lib/pure/osproc.nim(1246) waitForExit /Users/timothee/git_clone/nim/Nim_devel/lib/pure/includes/oserr.nim(94) raiseOSError Error: unhandled exception: Interrupted system call [OSError] Process 79961 exited with status = 1 (0x00000001)

so this points to a nim bug that I'll file and is (hopefully) fixable via something similar to https://github.com/nim-lang/Nim/pull/13232; however, the remaining issues I raised in https://github.com/nim-lang/Nim/issues/16838 are still valid, so there should be at least 1 bug open to track it