Failed to run 'elixir' command error in vs code

Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says

Failed to run ‘elixir’ command. ElixirLS will probably fail to launch. Logged PATH to Development Console.

I think elixir command is in current path

which elixir
/home/user/.asdf/shims/elixir

and

echo $PATH
...........:/home/user/.asdf/shims:.....................
What is my problem?

Can you show the full error output? Also what operating system are you using?

1 Like

How do you start VScode?

It might have a different view to your PATH than your shell, especially if you start it from a graphical environment rather from the terminal.

Please check the PATH logged into the console as explained by the error.

Please also check if the error persists when starting VScode from within a terminal that already is in the projects folder if you do not already open it that way. Depending on your operating system/flavor of it, you might need to run one of vscode . or code ..

full error output is this.

Failed to run ‘elixir’ command. ElixirLS will probably fail to launch. Logged PATH to Development Console.

and I am using manjaro linux

Yes you are right. Starting vs code from gui only shows error, and starting fro terminal using code . works fine

You probably add asdf only to the PATH in your shells RC file.

To make it available to your GUI as well you neet to add it to your .Xprofile or whatever is read by your GUI.

4 Likes

How can you do it under MacOS ?

Same problem for me with Gui on Mac & zsh.
No luck adding $HOME/.asdf/shims to PATH neither on $HOME/.zshenv nor $HOME/.zprofile

$HOME/.zshrc works for me

Your GUI does not care about settings in .zshenv and .zprofile, both of them are used by zsh only.

Though if your installed version of Elixir-LS is recent enough (I think it became added in 0.3.0 or 0.4.0), then asdf should be found by it if $HOME/.asdf/asdf.sh exists.

I saw that as well.

However asdf.sh is not there:

ls ${HOME}/.asdf/
  installs/      plugins/      repository/      shims/      tmp/

I did try creating a link

ln -s /usr/local/opt/asdf/asdf.sh asdf.sh

But failed miserably because the script points to directories relative to the original asdf.sh

I have asdf’s lastest version. And, BTW, this started happening to me in a newly migrated Mac (now) using Big Sur

Does your integrated terminal in vscode have the necessary envs? I guess thats what vscode uses to launch elixir-ls

Try a local user install as described by asdf rather than some package manager that installs system wide.

2 Likes

Thanks @NobbZ
Installed asdf again from sources –not using brew- and it works smoothly.

@lukaszsamson my integrated terminal is zsh and loads every other terminal outside of VSCode.