Skip to content

Instantly share code, notes, and snippets.

@emerleite
Forked from rubencaro/install_elixir.md
Created April 10, 2016 22:13
Show Gist options
  • Save emerleite/6d44f64d2a5b6be933c0b533234f1c88 to your computer and use it in GitHub Desktop.
Save emerleite/6d44f64d2a5b6be933c0b533234f1c88 to your computer and use it in GitHub Desktop.
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 kerl and exenv are your best friends.

Install needed system packages

These packages are only needed if you intend to compile erlang yourself, or to work with several versions at a time.

If you just need some erlang installation, you can do it with your regular package manager. If that is your case, then you may skip the kerl intallation process, and go straight to install exenv. It will depend on your distribution that you have a version of erlang that is recent enough. For instance, on Fedora you will probably have the last version released, but on Ubuntu you may have an older one.

Fedora

# install system build packages
sudo dnf install make automake gcc gcc-c++ kernel-devel git wget openssl-devel ncurses-devel wxBase3 wxGTK3-devel m4

# make wxWidgets3 visible to erlang (to build Erlang Observer)
mkdir -p ~/.local/bin
cd ~/.local/bin
ln -s /usr/bin/wx-config-3.0 wx-config
ln -s /usr/bin/wxrc-3.0 wxrc

Ubuntu

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

Arch

sudo pacman -S base-devel git curl wget wxgtk 

Install kerl

kerl lives in https://github.com/yrashk/kerl

# install kerl
mkdir -p ~/.local/bin
cd ~/.local/bin
curl -O https://raw.githubusercontent.com/spawngrid/kerl/master/kerl
chmod a+x kerl
cd

# just in case .local/bin is not in PATH, re-source will be needed
echo -e '\nPATH=$PATH:$HOME/.local/bin # Add custom bins to PATH' >> ~/.bashrc
echo -e '\nPATH=$PATH:$HOME/.local/bin # Add custom bins to PATH' >> ~/.bash_profile

On a new terminal:

kerl list releases

Build and install Erlang/OTP

# build erlang
kerl build 18.3 18.3

# install erlang
mkdir -p ~/.local/lib/erlang/18.3
kerl install 18.3 ~/.local/lib/erlang/18.3/

Add to .bashrc or .bash_profile:

# erlang custom runtime                                                             
test -s	"$HOME/.local/lib/erlang/18.3/activate"	&& source "$HOME/.local/lib/erlang/18.3/activate"

Now you can open a new terminal and try erl:

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

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

Or start Erlang Observer by erl -s observer start.

Install exenv

exenv lives in https://github.com/mururu/exenv

git clone git://github.com/mururu/exenv.git .exenv

Add to .bashrc or .bash_profile:

# elixir custom runtime
export PATH="$HOME/.exenv/bin:$PATH"
test -s "$HOME/.exenv/bin/exenv" && eval "$(exenv init -)"

Build and install Elixir

Elixir lives in https://github.com/elixir-lang/elixir

In a new terminal:

# download and place elixir
wget https://github.com/elixir-lang/elixir/archive/v1.2.3.zip
unzip v1.2.3.zip
mv elixir-1.2.3/ .exenv/versions/1.2.3

# compile & test elixir
cd .exenv/versions/1.2.3
make clean test

# setup global default elixir
exenv rehash
exenv global 1.2.3

Now you can try 'iex':

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

Interactive Elixir (1.2.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment