intellij-lsp
intellij-lsp copied to clipboard
LSP Error: Can't start server, plese check settings
Hello!
With PHPStorm 2020.1 i get the following error while opening a project or opening composer.json:
Kind Regards, Chris
As a temporary debugging measure, try putting the following into a script (or the Windows equivalent if that is your world):
#!/bin/sh
env > tmp.txt
And then set that script as the raw command for your desired extension type. I suspect you will find that the environment that your language server is being run in lacks needed environment variables to run node. I ran into the same thing trying to run a Python based language server that was only installed in a virtual environment. For me, the solution seems be to make a custom script that sets the needed environment variables and acts as a pass through for stdio.
I also had the same problem and was able to solve it.
The language server was written in node.js and published as npm package. I installed it via npm install some-lsp -g
.
In my terminal I was able to execute the server by the linked binary:
> some-lsp --stdio
When I tried to set this executable in the lsp configuration, I got the same error message that "node could not be found".
I solved it by resolving the linked binary to its pure command, meaning node /usr/local/lib/node_modules/some-lsp/server.js
and directly pointing to the executable of node.
Long story short: I ended up with the following working raw command:
/usr/local/bin/node /usr/local/lib/node_modules/some-lsp/server.js --stdio
Also a restart of the IDE might help after setting a new configuration.
I hope this helps others by using any node based lsp
@bghill What does the script look like? Namely, how do you ensure I/O is passed through correctly?
@holyjak: I don't know if this will work for others, but I really just added a minor tweak to one of the virtual env shim scripts. I didn't include it because I am using both pyenv and virtual-envs which is pretty specific.
#!/bin/sh
export PATH="/usr/local/bin:${PATH}"
# Why don't these set the env vars within this script?
# eval "$(pyenv init -)"
export PATH="/home/userid/.pyenv/shims:${PATH}"
export PYENV_SHELL=sh
command pyenv rehash 2>/dev/null
pyenv() {
local command
command="${1:-}"
if [ "$#" -gt 0 ]; then
shift
fi
case "$command" in
activate|deactivate|rehash|shell)
eval "$(pyenv "sh-$command" "$@")";;
*)
command pyenv "$command" "$@";;
esac
}
# eval "$(pyenv virtualenv-init -)"
export PATH="/usr/local/Cellar/pyenv-virtualenv/1.1.5/shims:${PATH}";
export PYENV_VIRTUALENV_INIT=1;
_pyenv_virtualenv_hook() {
local ret=$?
if [ -n "$VIRTUAL_ENV" ]; then
eval "$(pyenv sh-activate --quiet || pyenv sh-deactivate --quiet || true)" || true
else
eval "$(pyenv sh-activate --quiet || true)" || true
fi
return $ret
};
if ! [[ "$PROMPT_COMMAND" =~ _pyenv_virtualenv_hook ]]; then
export PROMPT_COMMAND="_pyenv_virtualenv_hook;$PROMPT_COMMAND";
fi
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
pyenv activate some-lsp-venv; some-lsp --check-parent-process