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

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.0

# 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 21.1
asdf install elixir 1.7.4

Then set them as the global version:

asdf global erlang 21.1
asdf global elixir 1.7.4

Now you can open a new terminal and try erl:

$ erl
Erlang/OTP 21 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.3  (abort with ^G)
1> 

Or start Erlang Observer by erl -s observer start.

And you can try 'iex':

$ iex
Erlang/OTP 21 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.7.4) - 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!

@NJichev

This comment has been minimized.

Copy link

commented Dec 18, 2017

Only Fedora, lol? Arch linux here, running versions 1.5.2

@AhmedSayed77

This comment has been minimized.

Copy link

commented Jan 21, 2018

I installed erlang and elixir by the steps mentioned in the official docs https://elixir-lang.org/install.html - erlang version 20.0 and elixir version 1.5.2-, then I used the steps mentioned here to install elixir 1.6 - I thought this will overwrite the present version with latest which are 20.2.2 for erlang and 1.6.0 for elixir. Although elixir -v command outputs 1.6.0, iex opens the repl in the 1.5.2 version, and erl opens in version 20.
I'm using ubuntu 16.04, any idea how to fix this?

@Rim-777

This comment has been minimized.

Copy link

commented Feb 24, 2018

On Linux Mint 18.3 I had to additionally activate the erlang locally with asdf local erlang 20.0 , otherwise elixir didn't work
Now everything works Ok. Thx!!!

@chostrander

This comment has been minimized.

Copy link

commented Mar 22, 2018

I installed on linux mint 18.3 and used elixir 1.6.0 and all is fine

@rubencaro

This comment has been minimized.

Copy link
Owner Author

commented Apr 7, 2018

@AhmedSayed77 @Rim-777 if you included everything on your bashrc, and after installation you run asdf global erlang <version> and asdf global elixir <version>, then iex and erl should be the ones you installed using asdf. adsf does not mess with your system's version, it simply puts itself before on the PATH, so when your shell tries to find which binary to run (the which command) it finds asdf's before the system's.

If it's not working, maybe you should go https://github.com/asdf-vm/asdf, https://github.com/asdf-vm/asdf-erlang.git or https://github.com/asdf-vm/asdf-elixir.git and find out about that kind of problems. It will probably be something related to how your system treats your PATH.

Hope that helped.

@NJichev I provide the recipes I know to be working for me, and I'm not an Arch user (yet). I work on Fedora and I'm forced to deploy to Ubuntu. If the only difference for Arch is the dependencies intallation, maybe you can give me the oneliner and I will put it on the guide, among the others. I will not be able to keep it up to date though.

@thovt93

This comment has been minimized.

Copy link

commented Apr 15, 2018

It working on Ubuntu 18.04 beta 2. I spend all day to install elixir and erlang. Thanks so much

@suryakun

This comment has been minimized.

Copy link

commented Jun 7, 2018

Brilliant, Worked on deepin 15.5.. You saved my time bro.. Thanks a lot

@rubencaro

This comment has been minimized.

Copy link
Owner Author

commented Aug 10, 2018

All OK on Fedora28 too, by the way.

@thevaliantx

This comment has been minimized.

Copy link

commented Aug 19, 2018

Failed install on Linux Mint 17,


~ $ iex
Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]

*** ERROR: Shell process terminated! (^G to start new job) ***

=ERROR REPORT==== 18-Aug-2018::22:35:57 ===
Loading of /home/cataclysm/.asdf/installs/elixir/1.6.4/bin/../lib/elixir/ebin/elixir.beam failed: badfile

=ERROR REPORT==== 18-Aug-2018::22:35:57 ===
beam/beam_load.c(1682): Error loading module elixir:
This BEAM file was compiled for a later version of the run-time system than R16B03.
To fix this, please recompile this module with an R16B03 compiler.
(Use of opcode 158; this emulator supports only up to 153.)

=INFO REPORT==== 18-Aug-2018::22:35:57 ===
application: elixir
exited: {bad_return,
{{elixir,start,[normal,[]]},
{'EXIT',
{undef,
[{elixir,start,[normal,[]],[]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,269}]}]}}}}
type: temporary

=INFO REPORT==== 18-Aug-2018::22:35:57 ===
application: compiler
exited: stopped
type: temporary

=ERROR REPORT==== 18-Aug-2018::22:35:57 ===
Error in process <0.27.0> with exit value: {{badmatch,{error,{elixir,{bad_return,{{elixir,start,[normal,[]]},{'EXIT',{undef,[{elixir,start,[normal,[]],[]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,269}]}]}}}}}}},[{'Elixir.IEx',start_iex,0,[{file...

@longvireak

This comment has been minimized.

Copy link

commented Oct 13, 2018

I already install Optional Erlang dependencies but still erlang can't generate document.
anyways it's work fine.

thank you :)

@rubencaro

This comment has been minimized.

Copy link
Owner Author

commented Feb 28, 2019

All OK for Fedora29.

@chrisidakwo

This comment has been minimized.

Copy link

commented Apr 27, 2019

Please correct this gist as follows:

It should be:

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

rather than:

echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc

The primary reason being that for those of us that'll end up using vscode for development, the ElixirLS extension will have a problem running the elixir command. Hence will keep crashing.

This is because adding asdf.sh to .profile will have the side effect of allowing applications started through dmenu — for i3 users— to have the elixir command available. Well this happens because stuff in .profile gets loaded when you login into your account, so anything there will be available to commands run through dmenu or desktop icons. But, stuff in .bashrc gets loaded everytime you open a terminal.

@rubencaro

This comment has been minimized.

Copy link
Owner Author

commented May 1, 2019

@chrisidakwo you should tell that to asdf maintainers. I merely cite their installation process.

BTW I'm also an vscode + i3 + asdf user and elixir programmer. What are the odds 😮? Anyway, can you please elaborate on the problem you have with ElixirLS? It works for me without your profile hack.

@rubencaro

This comment has been minimized.

Copy link
Owner Author

commented May 1, 2019

All OK for Fedora30 too.

@KazW

This comment has been minimized.

Copy link

commented Jul 16, 2019

I had to add the following line to ~/.kerlrc and remove the old build directory to get wx working so I could use debugger and observer:
KERL_CONFIGURE_OPTIONS="--with-wx-config=/usr/bin/wx-config-3.0"

This was on Fedora 30, after about an hour of struggling to fix this message: wx : wxWidgets not found, wx will NOT be usable

@rubencaro

This comment has been minimized.

Copy link
Owner Author

commented Jul 17, 2019

I will soon have the opportunity to try all this on a brand new machine, so I'll check that out. On my current machines I don't need to do any of that.

@KazW

This comment has been minimized.

Copy link

commented Jul 18, 2019

I think it maybe Fedora 30 specific, on 28, I didn't need to add kerl options. 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.