Installed Elixir via ASDF, shows successful but I’m getting “mix: command not found” errors

I installed Elixir using asdf. elixir -v shows the install was successful. Yet I’m getting “mix: command not found” errors.

~./bashrc path is referenced:

. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"

/etc/profile.d/elixir.sh is referenced:

export PATH=$PATH:/usr/local/lib/elixir/1.13.2-otp-24/bin

Erlang install is: erlang 24.2.1
Elixir install is: elixir 1.13.2-otp-24

I believe they are compatible.

I must be missing a path reference somewhere?
What am I doing wrong?

1 Like

two things you can try

asdf reshim

and

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

3 Likes

That’s not working.
If install outside of asdf using command:
sudo apt-get install elixir
The mix command then works.
Problem is I need to install a specific version.
Is there a way to do that without using asdf?

1 Like

Is mix binary present in $HOME/.asdf/shims/mix? Did you do asdf global elixir (version)?

2 Likes

asdf maintainer here. There couple that could be causing this. If what @massimo said did not work, I’d suggest re-reading the asdf getting started guide (Getting Started | asdf) and make sure you follow the instructions for your operating system and interactive shell.

If you do all that and it still doesn’t work, it means there something else interfering with asdf in your shell. I’ve found the following commands to be helpful when debugging versions installed with asdf:

type -a mix
type -a elixir

Both of these commands should print out a one or more paths to mix and elixir executables on your machine. If things are working properly you should see the asdf shim paths listed first ($HOME/.asdf/shims/mix and $HOME/.asdf/shims/elixir).

4 Likes

If you’re on a Mac my guide here might be worth a look too: How to set-up a Ruby and Elixir dev environment on macOS (2021) – (via @AstonJ)

1 Like

I see you’re asking questions about mix now, so assuming you resolved this. Could you share the solution?

1 Like

I tried so many things… I should have kept better notes. I think the solution ended up being some missing dependencies upstream.

Here’s what finally worked:

To set the version of Elixir:

  1. Open a terminal window.
  2. Navigate to your home directory by running the following command: cd ~
  3. Check if the .tool-versions file exists by running ls -a. If it doesn’t exist, create it by running touch .tool-versions.
  4. Open the .tool-versions file with a text editor of your choice. For example, you can use the following command to open it with nano: nano .tool-versions
  5. Add the following line to the file: elixir 1.13.2-otp-24.
  6. Save the changes and exit the text editor.

To check the current version of Elixir:

  1. Open a terminal window.
  2. Run the following command: elixir -v.

This will display the version of Elixir that is currently set on your system. If you’ve followed the steps above and set the version to 1.13.2-otp-24, then running elixir -v should display that version.

Same effect should be achievable by running asdf global elixir 1.13.2-otp-24 btw.

1 Like

asdf global elixir 1.13.2-otp-24

That’s what I said in April, but Emily reported it didn’t work :man_shrugging:

Then something super weird is going on, likely permission issues. We can’t help much if basic system expectations don’t hold up. She should troubleshoot and pursue. What’s even weirder is that just some file in the homedir made the whole thing work.

But can’t fault her really, especially if something you thought trivial wasted you a lot of time you’ll just be happy that you found a solution that worked eventually.

1 Like