What is the recommended way to use the VS Code extension with global purs and spago packages, using nvm?
spago build, test etc. work all fine via CLI. With VS Code extension, a locally installed purs/spago package also works for me by adding the "purescript.addNpmPath": true settings.json entry.
With a global installation, let’s assume a path /home/bela/.nvm/versions/node/v14.13.0/bin to the binaries. Then error output from VS Code "Output -> IDE PureScript" shows, that the extension is missing above binary entry in PATH environment:
Starting IDE server
Using sources from psc-package/spago packages (PURS_IDE_SOURCES not set)
Couldn't find IDE server, check PATH. Looked for: purs in PATH: <paths omitted here>
PureScript Language Server started
.bashrc contains the usual lines to initialize nvm (also tried .profile):
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
My second attempt has been to give an explicit path to spago and purs binary:
"purescript.pursExe": "/home/bela/.nvm/versions/node/v14.13.0/bin/purs",
"purescript.buildCommand": "/home/bela/.nvm/versions/node/v14.13.0/bin/spago build --purs-args --json-errors",
At first the output seems promising:
PureScript Language Server started
[Info - 6:57:33 PM] Resolved IDE server paths (npm-bin: false) from PATH of <...omitted again...> (1st is used):
[Info - 6:57:33 PM] /home/bela/.nvm/versions/node/v14.13.0/bin/purs: 0.13.8
[Info - 6:57:33 PM] Starting IDE server on port 15619 with cwd /home/bela/git/purescript-book/exercises/chapter2
Started IDE server (port 15619)
[Info - 6:57:34 PM] [Info] cachedb was changed from: Nothing, to: Just 2020-10-17 16:06:17.151016188 UTC @(main:Command.Ide app/Command/Ide.hs:205:25)
Though the language server still does not work properly - things like “Go to definition” don’t work. The “PureScript: Build” command now emits an error. Output panel:
[Info - 7:04:28 PM] Resolved build command (1st is used):
[Info - 7:04:28 PM] /home/bela/.nvm/versions/node/v14.13.0/bin/spago: 0.16.0
[Info - 7:04:28 PM] Running build command: /home/bela/.nvm/versions/node/v14.13.0/bin/spago build --purs-args --json-errors
[Info - 7:04:28 PM] e[31m[error] e[0mExecutable was not found in path: "purs"e[0m
[Error - 7:04:28 PM] Problem running build: didn't find JSON output
The line Executable was not found in path: "purs" might hint a bug in the extension. I would expect here the full explicit purs path, not the default one.
Has anyone experienced similar issues? Thanks in advance!