Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

Install needed system packages

Fedora

sudo dnf install make automake gcc gcc-c++ kernel-devel git wget openssl-devel ncurses-devel wxBase3 wxGTK3-devel m4 autoconf readline-devel libyaml-devel libxslt-devel libffi-devel libtool unixODBC-devel unzip curl

Ubuntu

sudo apt-get install build-essential git wget libssl-dev libreadline-dev libncurses5-dev zlib1g-dev m4 curl wx-common libwxgtk3.0-dev autoconf

Optional Erlang dependencies

If you want Erlang to generate its docs when compiling, or if you need the jinterface or the ODBC applications, then you may need to install some extra dependencies. The Erlang compilation script simply skips these if dependencies are not met, so all of this is optional. For Ubuntu and derivatives these dependencies seem to be the java and javac to be installed, and:

sudo apt-get install libxml2-utils xsltproc fop unixodbc unixodbc-bin unixodbc-dev

Install asdf and its plugins

asdf lives in https://github.com/asdf-vm/asdf

Follow its installation instructions, which at the moment of writing were:

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

# For Ubuntu or other linux distros
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc

On a new terminal, install Erlang and Elixir plugins:

asdf plugin-add erlang
asdf plugin-add elixir

Install Erlang and Elixir

asdf install erlang 22.0.7
asdf install elixir 1.9.1-otp-22

Then set them as the global version:

asdf global erlang 22.0.7
asdf global elixir 1.9.1-otp-22

Now you can open a new terminal and try erl:

$ erl
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Eshell V10.4.4  (abort with ^G)
1> 

Or start Erlang Observer by erl -s observer start.

And you can try 'iex':

$ iex
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.9.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

Use asdf .tool-versions file to manage which version is active on each of your projects.

Enjoy!

@nastari
Copy link

nastari commented Oct 29, 2020

Outdate. 🐎

@rubencaro
Copy link
Author

rubencaro commented Oct 29, 2020

Outdate. racehorse

@nastari Yes you're totally right. It's been a while since I touched Elixir code and this guide was only meant for myself and my close colleagues, so it gets old. Maybe you can just make a fork and keep your own guide up to date. You'd do good not depending on this one anyway.

Anyway, the main process is still valid, and as the first line states, Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing. Maybe on newer Fedora (now 33) or newer distros in general some system packages changed naming. Feel free to fork your copy and fix it. I can link it here if you want to help others find an up to date guide to this.

👍

@fbuys
Copy link

fbuys commented Jun 8, 2021

Commands I used to install erlang:

asdf plugin-add erlang
asdf list-all erlang
asdf install erlang 24.0.2
asdf global erlang 24.0.2
iex

Commands I used to install elixir:

asdf plugin-add elixir
asdf list-all elixir
asdf install elixir 1.12.1-otp-24
asdf global elixir 1.12.1-otp-24
elixir -v

@Terkwood
Copy link

Terkwood commented Jul 18, 2021

if you see an error like wxWidgets was not compiled with --enable-webview or wxWebView developer package is not installed, try

sudo apt install libwxgtk3.0-gtk3-dev  libwxgtk-webview3.0-gtk3-dev

Hopefully, you can then run asdf install erlang 24.0.4.

See also: asdf-vm/asdf-erlang#203

@KoltPenny
Copy link

KoltPenny commented Dec 2, 2021

At first it was fine but now mix is confused:

/home/user/.asdf/shims/mix: line 4: Mix.start: command not found
/home/user/.asdf/shims/mix: line 5: Mix.CLI.main: command not found

It still works fine when I do iex -S mix but it's a pain for my workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment