Setting Up Elixir Like a Rubyist

April 05, 2016

Getting into the Elixir Programming Language

Elixir Logo

I use Ruby in my day job, but recently I’ve been dabbling with Elixir. I’ve come to appreciate the Ruby ecosystem of tools to get setup and running – bundler and rvm (or chruby or rbenv depending on your preferences).

But I’m used to RVM and other environment managers – where is the RVM for Elixir?

It turns out there’s a few options for Elixir. I ended up choosing Kerl and Kiex. Here is how I installed it on my Ubuntu desktop and Mac OSX laptop.

Installing Kiex

Kiex is like RVM in that it allows you to switch between different Elixir versions and build them.

curl -sSL https://raw.githubusercontent.com/taylor/kiex/master/install | bash -s

# In .bashrc (or .zshrc if you use z shell), add the following:

[[ -s "$HOME/.kiex/scripts/kiex" ]] && source "$HOME/.kiex/scripts/kiex"

Installing Kerl

Because Elixir runs on top of Erlang, you need a way to build and install Erlang/OTP instances.

$ mkdir ~/.kerl

$ cd ~/.kerl

$ curl -O https://raw.githubusercontent.com/yrashk/kerl/master/kerl

$ chmod a+x kerl

$ kerl list releases

$ kiex list known

#can now use elixir

$ kiex install 1.5.1
$ kiex use 1.5.1

$ mkdir ~/erlang_install/20.0

kerl build 20.0 20.0

kerl install 20.0 ~/erlang_install/20.0

You can activate this installation running the following command:

. ~/erlang_install/20.0/activate

In .bashrc (or .zshrc if you use z shell), add the following:

. ~/erlang_install/20.0/activate

Later on, you can leave the installation typing: kerl_deactivate

You can delete a build with kerl delete build 20.0.

Source: https://github.com/yrashk/kerl – follow instructions and add export PATH=”$PATH:$HOME/.kerl” to .bashrc (or .zshrc or any other .rc file)

Troubleshooting

If you get a debug message such as:

Kiex sourcing line not found in ~/.bashrc, ~/.bash_profile, ~/.profile, ~/.zshrc, or ~/.zsh_profile

Add the following to your shell’s config file (.bashrc/.zshrc/.cshrc):

[[ -s "$HOME/.kiex/scripts/kiex" ]] && source "$HOME/.kiex/scripts/kiex"

Other useful commands

kerl list installations

erl version -- list Erlang version, you will see something like:

Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.8.3

Profile picture

Written by Bruce Park who lives and works in the USA building useful things. He is sometimes around on Twitter.