DEV Community

Cover image for Install Elixir and Erlang with asdf version manager
Benjamín Silva
Benjamín Silva

Posted on • Originally published at 96codes.dev

Install Elixir and Erlang with asdf version manager

If you come from Ruby on Rails for example, it's very common to have rvm to manage your Ruby versions, but also you would probably need to install nvm to manage versions for Node.js too (since Rails now has webpack assets pipeline).

This same story happens with Phoenix Framework, but even adding a third language to the stage: Erlang, Elixir and Node.js

So how do we manage all involved languages versions with one single version manager?

meet asdf version manager

You can install it following the installation instructions

After installing, simply install an Erlang version by running

# to add the erlang plugin
$ asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git
# to list all available erlang versions
$ asdf list-all erlang
Enter fullscreen mode Exit fullscreen mode

A long list may appear, you usually would want to install the latest (at the bottom)

$ asdf install erlang 22.0.7
Enter fullscreen mode Exit fullscreen mode

After installing Erlang, you can proceed to install Elixir with the same approach

$ asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
$ asdf list-all elixir
$ asdf install elixir 1.4.9
Enter fullscreen mode Exit fullscreen mode

Then, in your project folder, you can tell asdf to select specific versions of software by adding a .tool-versions file with some content like this:

elixir 1.9.1
erlang 22.0.7
nodejs 10.16.0
Enter fullscreen mode Exit fullscreen mode

If you call asdf current to see whats the current versions of each configured plugin inside the current working directory

$ asdf current

  elixir   1.9.1    (set by /Users/benja/dev/newslettex/.tool-versions)
  erlang   22.0.7   (set by /Users/benja/dev/newslettex/.tool-versions)
  version 10.16.0 is not installed for nodejs
Enter fullscreen mode Exit fullscreen mode

You notice that it says node 10.16.0 is not installed, because it reads the .tool-versions and finds out we don't have the requested nodejs version. To install it, simply:

$ asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
$ brew install coreutils
$ brew install gpg
$ bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
$ asdf install nodejs 10.16.0
Enter fullscreen mode Exit fullscreen mode

Now you have all your versions managed under asdf.

Top comments (6)

Collapse
 
adolfont profile image
Adolfo Neto

Does it bring Erlang docs to iex?

Collapse
 
silva96 profile image
Benjamín Silva • Edited

I'm pretty sure it's not related to asdf itself but to IEx/Erlang.

Check this:

elixirforum.com/t/solved-is-it-pos...

Collapse
 
adolfont profile image
Adolfo Neto • Edited

Yes, it is related to asdf.

Erlang has to be installed with docs. It works, but it is not the default way to install Erlang with asdf.
See Getting Erlang documentation.

Thread Thread
 
silva96 profile image
Benjamín Silva

Great, thanks for noting it!

Collapse
 
itzami profile image
Rui Sousa

Actually had to use a different Elixir version this week and got a bit confused with the existing guides so this is extremely handy. Thank you!

Collapse
 
silva96 profile image
Benjamín Silva

I'm Glad it helped you!