[X] You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain
Bug description
lsp requires both exec-path and the PATH environment variable to contain a directory with node and npm. When running Emacs from the command-line this isn't an issue, because nvm ensures that PATH gets set via .profie. However when launching Emacs from the window system (e.g. the "Dash" in Gnome) the shell is not involved so PATH isn't set. This leads to confusing errors (in messages / lsp-log) as soon as you try to install a server:
LSP :: Server ts-ls install process failed with the following error message: Unable to find a way to install typescript.
One can add the nvm directory manually to exec-path, but this isn't enough:
/home/dhd/.nvm/versions/node/v20.14.0/bin/npm -g --prefix /home/dhd/.emacs.d/.cache/lsp/npm/typescript install typescript
/usr/bin/env: ‘node’: No such file or directory
Adding it to PATH in .emacs instead doesn't work either, giving the same error as before:
Unable to install typescript via `npm' because it is not present
But if you add it to both exec-path and PATH then everything is fine. This is what would have happened had the PATH variable been set prior to launching Emacs, obviously. So the workaround is to add something like this to .emacs (which only works on Unix, sorry!)
One could also use nvm.el but unfortunately it requires you to specify an explicit version and can't just get the default one (which is found in ~/.nvm/alias/default in most cases)
Thank you for the bug report
lsp-mode
related packages.M-x lsp-start-plain
Bug description
lsp requires both
exec-path
and thePATH
environment variable to contain a directory withnode
andnpm
. When running Emacs from the command-line this isn't an issue, becausenvm
ensures thatPATH
gets set via.profie
. However when launching Emacs from the window system (e.g. the "Dash" in Gnome) the shell is not involved soPATH
isn't set. This leads to confusing errors (in messages / lsp-log) as soon as you try to install a server:One can add the
nvm
directory manually toexec-path
, but this isn't enough:Adding it to
PATH
in.emacs
instead doesn't work either, giving the same error as before:But if you add it to both
exec-path
andPATH
then everything is fine. This is what would have happened had the PATH variable been set prior to launching Emacs, obviously. So the workaround is to add something like this to.emacs
(which only works on Unix, sorry!)One could also use nvm.el but unfortunately it requires you to specify an explicit version and can't just get the default one (which is found in
~/.nvm/alias/default
in most cases)Steps to reproduce
M-x lsp-install-server ts-ls
Expected behavior
lsp
findsnode
andnpm
somehow ;-)Which Language Server did you use?
ts-ls
OS
Linux
Error callstack
No response
Anything else?
The problem is known for some time but there is a lot of noise in related bug reports that make it hard to understand what is actually going on!