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?
1 Like

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 ..

2 Likes

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

1 Like

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.

3 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.

Hello,

I am using VS Code via Windows 10/WSL (erlang/elixir installed via asdf) and I also get

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

I even do not know where/what this “Development Console” is (google didn’t help).

Is someone able to help me?

Click on View → Terminal
Select output tab
Then select ElixirLS from the dropdown

2 Likes

@Facundo I can confirm that! Just <upgraded> my MacBook Air M1 to BigSur - and the next thing I noticed was that ElixirLS fails to start in VSCode

my .zshrc is good as is my asdf local elixir 1.12.0

I may have installed asdf with brew first - but my current installation is tucked away safely in $HOME/.asdf :sunglasses:

Tried iex from CLI only to learn that elixir wasn’t the issue at all - erl was! (Note: I run all my workbench stuff in containers which is probably why I haven’t noticed)

Once I got my asdf global erlang 24.1 out of the way - all was good in VSCode on macOS BigSur land :smile:

3 Likes

Actually, “development console” in that error refers to Chromium’s Electron’s VSCode’s development tools console, which is under the Help menu header on MacOS, and… might be in a similar enough part of the Windows menu if you dig around for it a bit, @Nefcairon.

3 Likes

This ended up being the solution for me here on Groundhog’s Day, 2022. I forgot to set my global erlang asdf.

Rectified, relaunched, resplendent.

3 Likes

Setting erlang and elixir globally solve the issue for me as well
asdf global erlang <your_version>
asdf global elixir <your_version>

7 Likes