Installing Elixir on Mac OS
While it might seem easy enough to brew install elixir
, I opted to use mise
as a version manager, which was recommended by a kind soul on bluesky as an alternative to using asdf
.
For the uninitiated, both asdf
and mise
are CLI tools that help you manage separate versions of dependencies like Elixir & Erlang, such that you can use different versions per project, and have the right ones available as soon as you cd
into the directory. Neat!
I initially wrote this guide targeting asdf
as it was recommended by the official docs, but after trying both, I can attest that mise
is far supperior. I left the original post at the bottom so you can see the difference. Both options presume you already have brew
installed.
Installing everything via mise
brew install mise
# Initialize mise in your shell (add to ~/.zshrc or ~/.bashrc)
eval "$(mise activate)"
# Install latest stable versions of erlang and elixir
mise use erlang@latest
mise use elixir@latest
# Verify installations
mise list
So easy! See below for using asdf
.
Installing asdf + plugins
brew install asdf
In order for asdf
to know about the various versions of Erlang & Elixir, you need to add them as plugins:
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
To verify everything is working, you can run the following commands to see all the available versions of each:
asdf list-all erlang
asdf list-all elixir
Installing Erlang/OTP
You'll want to install Erlang first, so find the most recent stable version at the bottom of the list. Mine was 27.2
so I ran:
asdf install erlang 27.2
Verify it's working with erl --version
.
Installing Elixir
You'll want to match the elixir release with the OTP version you have installed. For example, since I now have erlang 27.2
, I want to install the latest elixir build with OTP 27, which is 1.18.1-otp-27
.
asdf install elixir 1.18.1-otp-27
You can verify the installation with elixir -v
. Congrats!
Setting asdf globals
You can set your current versions as the global defaults via:
asdf global erlang 27.2
asdf global elixir 1.18.1-otp-27
If you want to use different versions per project, you can set alternative versions in a different directory via:
asdf local erlang XX.X
asdf local elixir X.XX.X-otp-XX
Good luck!