Failed to run 'elixir' command error in vs code

I solved it using:
sudo dnf install erlang-dialyzer
sudo dnf install erlang-edoc
asdf local elixir 1.13.3
asdf local erlang 24.3.4

Installing it globally worked for me on a M1 mac even with asdf installed via homebrew.

Same! this works for me! thank you so much!

I have Manjaro with asdf and zsh.

In my home I creatd a .profile file with this content:

echo 'export PATH="$PATH:/home/<user>/.asdf/shims:/home/<user>/.asdf/bin"' > ~/.profile

Just change <user> by your user name and it should work. If you already have this file I suggest you to do a backup.

2 Likes

I remove asdf from brew and install again with git and add asdf plugin to my .zshrc file

I prefer launching VSCode from the Mac OS toolbar, and it results in this error. Setting elixir and erlang global versions using asdf global ... doesn’t work for me.

VSCode developer console reports:

[Extension Host] /bin/sh: elixir: command not found | p @ console.ts:137
Failed to run 'elixir' command. ElixirLS will probably fail to launch. Logged PATH to Development Console. | c @ notificationsAlerts.ts:42
[Extension Host] Failed to run 'elixir' command. Current process's PATH: /usr/bin:/bin:/usr/sbin:/sbin

It does work, however, if I launch VSCode from the terminal using code .

1 Like

Did you figure this out?

1 Like

For me the solution was to create the file $HOME/.tool-versions with content like this (matching the installed versions in system):

erlang 26.2.5
elixir 1.16.3-otp-26

None of the above proposed fixes work for me.
Let’s recap what I did.

As many, I installed asdf as described in the documentation, aka:

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"

Then, I installed erlang, and then elixir, as pointed out in the docs, as follows:

asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
asdf install erlang 26.2.5
asdf global erlang 26.2.5
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
asdf install elixir 1.16.3-otp-26
asdf global elixir 1.16.3-otp-26 

My $HOME/.tool-versions is the following:

erlang 26.2.5
elixir 1.16.3-otp-26

At this point iex and erl work with no issue.
But the vs code extensions don’t work yet.

Then I tried searching for $HOME/.asdf/asdf.sh but no file was found.
Turns out the file was there, but I had no permissions on it and thus it wasn’t usable.

So, I temporarily chmod 777 $HOME/.asdf/asdf.sh, just to be sure, but again the vs code extensions don’t work yet.

This is the output I get, again:

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

(the PATH is not logged on the dev console, by the way)

And also:

OTP compiled without EEP48 documentation chunks

(which appears frequently)

Finally:

Unable to find formatter for [...]/file.ex: Mix project is not loaded

I’m not sure what to do at this point. I can’t seem to find reliable documentation nor troubleshooting anywhere, so I try here :cry:

Elixir is a blast but I’m honestly surprised it is this hard to actually get “up and running” (for reals tho, not just tooling around).

1 Like

@lucavenir , sorry to not be able to help but I think there’s an outside chance :person_shrugging: that this is some sort of regression or compatibility issue with ElixirLS.

I’ve been happily using Elixir in vsCode since circa 2015 and it stopped working maybe a week ago. I’m at the exact same place you are right now—your post above—but only part-time devving and don’t have the bandwidth to debug further at the moment.

On a Mac M1, for what it’s worth:

erlang 26.2.5
elixir 1.16.2-otp-26

Apologies for not being more helpful the moment. Just wanted you to know you’re not the only one. Anyone here have further ideas?

Hello there again,

Thank you for your kind response. I just want to add my further experience; I didn’t give up, but even when switching OS isn’t solving the issue… that’s a good sign to bail.

Here’s what I tried:

  • re-installed elixir, erlang and the extensions from scratch, nothing
  • re-installed vscode from scratch along with elixir/erlang/extensions/etc., nothing
  • gave up on using Ubuntu 22.04 to write elixir code, formatted and erased everything, re-installed linux with FedoraOS distro, reinstalled erlang/elixir/vscode/extensions… still nothing

Let me say it again - this ecosystem really deserves a unified DX when it comes to tooling. Don’t get me wrong, I love Elixir and I love working with it. And Phoenix, too.

Nonetheless, and luckily, lexical is a thing. I’m sticking to this solution until I figure out why/how/what makes tooling hard to work with.