Why would you want to use Elixir master?

There are really cool upcoming features in next Elixir release. This sentence is true no matter which one is the upcoming release, in my experience ;). It would be awesome to - on occasion - try some of these out. The upcoming v1.6 release has an Elixir code formatter built in, and you will need it if you want to cut the code formatting discussion now with mix format.

Being able to easily check out, update and switch between versions might also help you contributing to Elixir itself. The source is on your computer - open it and read it :D.

Manual approach

It’s pretty easy to compile Elixir from source. You will need the usual packages for Erlang, build-essentials, development versions of readline and openssl libraries, make and - optionally wxgtk3 library if you want to use graphical tools that come with Erlang - such as the Observer.

On Ubuntu, install those with something like:

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

the package versions might differ between Ubuntu releases, but overall that’s all you need.

Check out the most recent master from Github:

$ git clone https://github.com/elixir-lang/elixir.git

and build it:

$ cd elixir
$ make

At this point, you will have the usual command-line tools that come with Elixir (elixirc, iex, mix) built and installed in bin/ directory.

To use this locally built version of Elixir, all you need to do is to set up the $PATH variable to point to your bin/ directory where those executables were put.

Using asdf version manager

Manual approach is fine, but you might be already using a version manager to manage different Elixir versions. If you chose asdf version manager, you are lucky - it supports installing Elixir form master with one simple command:

$ asdf install elixir ref:master

If you do not have asdf version manager installed, I highly recommend you do. It’s got pretty shitty name, but is an awesomely reliable tool, which I do use to manage my Ruby, Elixir, Node.js and Erlang versions. You will need asdf-erlang and asdf-elixir plugins, and you will need to install Erlang before you install Elixir.

If the build succeeds, a ref:master should be listed among installed versions:

$ asdf list elixir

Use it globally with asdf global elixir ref:master or within the scope of project with: asdf local elixir ref:master.

asdf installs the Elixir in ~/.asdf/installs/elixir/ref-master (note the “-“ replaces “:” in directory name. You can easily update this installation to newer version of Elixir with:

$ cd ~/.asdf/installs/elixir/ref-master
$ git checkout master
$ git pull
$ make clean && make

After that, and elixir -v should show you new development version, with version number pointing to the latest commit on master.

Since asdf simply expects the Elixir repository with built executables to be present in it’s ~/.asdf/installs/elixir directory, you can also check out Elixir source from Github to other directory on your system, say ~/Projects/elixir and symlink it there:

$ cd Projects
$ git clone https://github.com/elixir-lang/elixir.git
$ cd elixir
$ make
$ ln -s `pwd` ~/.asdf/installs/elixir/ref-master

And the ref:master/ref-master version of Elixir should be listed as one of installed, available versions:

$ asdf list elixir

That’s all folks!

Post by Hubert Łępicki

Hubert is partner at AmberBit. Rails, Elixir and functional programming are his areas of expertise.