Setting Up Elixir

The Elixir install documentation recommends installing through your os distribution, e.g.:

$ #osx
$ brew install elixir

$ #archlinux 
$ pacman -S elixir

This works well, but you will run into issues if you want to test/run your app on different versions of Erlang or Elixir. Also if you have multiple Elixir projects over time there is a very strong chance all those apps will be running different versions.

The solution to any of these headaches is the version manager, asdf.

Setting Up asdf on Mac OS or Linux

We can run the following commands to get asdf installed on your system.

$ git clone ~/.asdf --branch v0.3.0
$ echo -e '\n. $HOME/.asdf/' >> ~/.bashrc
$ echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
$ source ~/.bashrc

Installing Erlang

Now that we have asdf set up we can get Erlang installed, which is a prerequisite for installing Elixir.

$ asdf plugin-add erlang
$ asdf install erlang 19.3

The last command to install Erlang will take a little time, but once it is complete you will have Erlang installed through asdf.

If you ran the command to see the current version of Erlang installed with asdf at this point you would get an error.

$ asdf current erlang
/Users/df/.asdf/lib/ line 71: [: !=: unary operator expected
No version set for erlang

To set a default version to use on your system you need to create a .tool-versions file in your home directory.

$ echo -e 'erlang 19.3' >> ~/.tool-versions

Now you have a default Erlang set and if you run asdf current erlang again you will see that you no longer get an error.

Installing Elixir

Now that we have Erlang installed we can get Elixir set up with asdf.

$ asdf plugin-add elixir
$ asdf install elixir 1.4.4

We now need to set our default version of Elixir in our .tool-versions file like we did with Erlang.

$ echo -e 'elixir 1.4.4' >> ~/.tool-versions


You now have Elixir and Erlang set up through the version control manager asdf. When you ever have the need for a new version of either you will be able to install the versions without affecting the other.