How to Use ASDF to Install Elixir and Erlang

ASDF is a tool version manager that can manage multiple language runtime versions on a per-project basis. It is like gvm, nvm, rbenv & pyenv (and more) all in one! Simply install your language's plugin!

In this tutorial, We'll learn how to install specific versions of Elixir and Erlang/OTP using the ASDF version manager on macOS or Linux.

Install ASDF

The ASDF version manager is a command-line tool that is available on GitHub. It uses curl and git to install various languages.

Install Prerequisites

To install the curl and git utilities, run:

brew install coreutils curl git  # on macOS with Homebrew
sudo apt install curl git        # on Linux

You can learn more about Homebrew on macOS here.

Clone ASDF

With the prerequisites installed, now clone the ASDF project:

git clone ~/.asdf

If you ever wish to remove ASDF, you can do so by removing .asdf from your home directory and undo the configuration changes described below.

Configure Your Shell

Finally, include ASDF in your shell's configuration. For zsh, add the following to ~/.zshrc:


Alternatively, if you use oh-my-zsh, add asdf to your plugin configuration. To include ASDF in your configuration when using a different shell, consult the documentation.

Install Plugins

ASDF uses a plugin system to support multiple languages. For a typical Elixir project, you will need the Elixir and Erlang plugins:

asdf plugin add erlang
asdf plugin add elixir

If your project requires Node.js, you can also install the nodejs plugin.

Install Erlang/OTP

With ASDF and its plugins installed, you can now install Elixir and Erlang. If your project has a .tool-versions file with entries for elixir and erlang, you can install the correct versions by running the following from inside the project:

1asdf install


The .tool-versions file is much like .nvmrc and .ruby-version files, except that it lists the names and versions of multiple languages. In general, the names in this file should match the names of the language's plugin (e.g. nodejs for Node.js).

If you do not yet have a .tool-versions file, or want to install Elixir and Erlang globally, use the following to see a list of all available Erlang/OTP versions:

asdf list-all erlang
# ...
# ...

Unlike other version managers, ASDF requires you to specify a precise version of the language to install. To install version 23.2.1 of Erlang, run:

asdf install erlang 23.2.1

Warning: This installation will take some time while it compiles Erlang from source.

Erlang will compile modules based on the available libraries from your system. For example, some features (such as the built-in observer) require wx libraries. You may see messages during the installation about omitted modules, which will not affect the rest of the runtime.

Install Elixir

Once the Erlang runtime is installed, you are ready to install Elixir. To see a list of all available versions, run:

asdf list-all elixir
# ...
# ...

Notice that each Elixir release has multiple versions compiled with different major versions of Erlang/OTP. To maximize compatibility between Elixir and the Erlang runtime, choose a -otp-XY version that matches the major version of the runtime you installed in the previous step. For example:

asdf install elixir 1.11.2-otp-23

Installing Elixir takes significantly less time than installing Erlang/OTP.

Set Versions

Now that you have Elixir and Erlang/OTP installed, you can save your chosen versions in a project. From the root of the project, run:

asdf local erlang 23.2.1
asdf local elixir 1.11.2-otp-23

Replace the versions above with those you used during installation. This will create a .tool-versions file in your project, which will instruct ASDF which versions to use. If you'd like to set a global, or default, version, run:

asdf global erlang 23.2.1
asdf global elixir 1.11.2-otp-23

This will create a .tool-versions file in your home directory. ASDF will use these versions whenever a project doesn't specify versions of its own.

ASDF is a popular version manager for Elixir projects because it manages both Elixir and Erlang versions. Include a .tool-versions file in your projects to help contributors get up-and-running quickly, and don't forget to leverage the -otp-XY versions of Elixir for the best compatibility.

Originally published by AJ Foster at Pluralsight

#linux #macos 

How to Use ASDF to Install Elixir and Erlang
1.10 GEEK