Installing elixir via asdf shows zsh: command not found: iex

I tried installing

elixir 1.11.2
erlang 23.3.4

via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them via ‘asdf list elixir’ or ‘asdf list erlang’ the correct versions are listed but not usable.
→ it keeps on showing: zsh: command not found: iex

I had the latest version of Elixir installed by homebrew before, which worked flawlessly.
Before the installation via asdf I uninstalled the brew installed version.

It keeps on not working after updating my OS(Monterey 12.2.1), updating brew, cleaning up brew, copying suggested lines to zsh, restarting my computer, etc.

Does anyone runs into the same issue or knows a workaround? Am I overlooking something?

Many thanks!

2 Likes

Can you check the output of the following commands:

asdf which elixir
asdf which iex
1 Like

~/.asdf/installs/elixir/1.11.2-otp-23/bin/elixir
~/.asdf/installs/elixir/1.11.2-otp-23/bin/iex

1 Like

Did you try asdf reshim ?

2 Likes

Yes of course.

Using iex with full path works but using only iex command does not work ?

~/.asdf/shims/ folder is included in path.

Commands like iex, elixir, erl are resolved to files in the shims folder.

You can check $PATH variable if ~/.asdf/shims/ folder is included.

Did you install asdf using brew ?

1 Like

Also not sure if it’s any help, but try following this guide - this has always worked for me on a new Mac or after a clean install.

3 Likes

I have

plugins=(
...
asdf
...

in .zshrc
and then

asdf reshim elixir
3 Likes

Try mix local.hex what that do for you

I would also try a dumb terminal with no zsh, see if that functions normally so you can narrow the surface area of this bug.

1 Like

So if I type in these commands:

(base) ➜ ~ asdf which elixir
HOME/.asdf/installs/elixir/1.11.2/bin/elixir
(base) ➜ ~ HOME/.asdf/installs/elixir/1.11.2/bin/elixir --version
HOME/.asdf/installs/elixir/1.11.2/bin/elixir: line 230: exec: erl: not found

I get the error above.
So I tried fixing it with setting export erl=HOME/.asdf/installs/erlang/23.3.4/bin/erl
in ~/.zshenv

However
(base) ~ echo $erl
shows me
HOME/.asdf/installs/erlang/23.3.4/bin/erl

but just typing
(base) ~ erl
zsh: command not found: erl

Seems to me this is a zsh issue or I’m making a mistake?

1 Like

Setting erl variable in environment is different from adding it to $PATH.

if you want to erl to path - it should be
export PATH=<path_to_exec_parent_folder>:$PATH

You should be adding ~/.asdf/shims if it is not present.
Can you try this:

export PATH=~/.asdf/shims:$PATH

And check iex, erl, elixir commands

14 Likes

That worked thank you!

5 Likes

I tried doing this and it worked fine, but after restarting my laptop asdf is gone. I tried this twice ad asdf gets uninstalled both the times after restarting my laptop, what should I do?

Did you put the export command right into your terminal or did you put it in your shell configuration file?(something like ~/.bashrc or ~/.zshrc)

The first solution will only work for your current terminal session, whereas the latter solution will run the export command at each terminal session startup.

3 Likes

in my shell config file. Sorry for the late response, the problem got solved after sometime without me doing anything.

glad I found this.
this works thanks

recently had this problem, noticed that on .zshrc, I got my plugins+=(asdf) line commented. Having that uncommented, now all works well.

2 Likes

Thank you! it worked correctly