lobo_tuerto's notes
for greatly improving DX

Install Elixir in Linux

The easiest way to install Elixir in Linux is through ASDF, period.

📅Date08 March 2018Updated17 October 2021

GitHub for asdf-erlang
GitHub for asdf-elixir

Version managers

Using version managers is great. To be able to install multiple coexisting versions of the languages you use provides valuable DX.

I’ve been using asdf to install Erlang and Elixir with OTP support, so far it’s been without flaw.

Install asdf

Clone the GitHub repository:

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1

Add some lines to your .profile and .bashrc files:

echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.profile
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc

Make changes effective with:

source ~/.profile
exec $SHELL

If we add asdf.sh to ~/.profile instead of ~/.bashrc, it will have the side effect of allowing applications started through dmenu —for i3 users— to be able to call ASDF installed commands.

This is because stuff in ~/.profile gets loaded when you login into your account, so anything there will be available to other programs run through dmenu or desktop icons.

On the other hand, stuff in ~/.bashrc gets loaded everytime you open a terminal. So another way to have VSCode work with ASDF stuff would be to just start code from the CLI.

Update asdf

To update to the latest stable version just type:

asdf update

Install Erlang and Elixir

Let’s get some dependencies for Erlang —we need WxWidgets so we can use :observer.start:

sudo pacman -S unixodbc wxgtk2

# You already have in your system most of what's needed.
# The full list of dependencies would be:
# sudo pacman -S base-devel glu libpng libssh mesa ncurses unixodbc wxgtk2

For Ubuntu you need these dependencies:

sudo apt install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-dev \
libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev

Finally install Erlang and Elixir:

asdf plugin-add erlang
asdf list-all erlang
asdf install erlang 24.1.2
asdf global erlang 24.1.2

asdf plugin-add elixir
asdf list-all elixir
asdf install elixir 1.12.3-otp-24
asdf global elixir 1.12.3-otp-24

To enable the REPL history in IEx:

echo -e '\nexport ERL_AFLAGS="-kernel shell_history enabled"' >> ~/.bashrc

If using Visual Studio Code try out the ElixirLS extension.

Install Hex

Let’s take on Hex the package manager now:

mix local.hex

You can now print some info about your Elixir stack with:

mix hex.info

You’ll see something along the lines of:

Hex:    0.21.3
Elixir: 1.12.3
OTP:    24.1.2

Built with: Elixir 1.12.3 and OTP 22.3

Install Phoenix

For completeness’ sake let’s install the latest version of Phoenix:

mix archive.install hex phx_new

# Want to install a specific version?
# mix archive.install hex phx_new 1.5.7
# mix archive.install hex phx_new 1.6.0-rc.0

To create an API only app, try with this command:

mix phx.new my-app --app my_app --module MyApp --no-html

If you want to follow up on building an API using Elixir, check this out:
Building a JSON API with Phoenix and Elixir

That’s it!

Got comments or feedback?
Follow me on