I like to try out different versions of Elixir including release candidates . This can be especially useful when I want to try out new features and write about them before the features make it into an official Elixir release. An example of this would be last month’s post on the Elixir’s new Special form “with”
The tool I use to manage multiple versions of Elixir is Kiex.
Kiex’s documentation is quite good and you should refer to it for the basic installation.
The commands I use most frequently are:
kiex list known- to list all the Elixir versions Kiex knows about:
kiex install <version>to install Elixir version
<version>on my system.
kiex use <version>to setup my current shell to use Elixir version
So for example, right now the known versions are:
kiex list known Getting the available releases from https://github.com/elixir-lang/elixir/releases Known Elixir releases: 1.2.1 1.2.0 1.2.0-rc.1 1.2.0-rc.0 1.1.1 1.1.0 1.1.0-rc.0 0.9.3 0.9.2 0.9.1 0.9.0 0.8.3 0.8.2 0.8.1 0.8.0 0.7.2 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 1.0.0 1.0.0-rc2 1.0.0-rc1 0.15.1 0.15.0 0.14.3 0.14.2 0.14.1 0.14.0
There are plenty of versions to choose from including release candidates. And, Elixir 1.2.1 was released yesterday! I’ll install it like this:
$ kiex install 1.2.1 Switched to branch 'master' Your branch is behind 'origin/master' by 289 commits, and can be fast-forwarded. (use "git pull" to update your local branch) remote: Counting objects: 394, done. remote: Compressing objects: 100% (47/47), done. remote: Total 394 (delta 202), reused 183 (delta 183), pack-reused 162 Receiving objects: 100% (394/394), 123.77 KiB | 0 bytes/s, done. Resolving deltas: 100% (245/245), completed with 76 local objects. From https://github.com/elixir-lang/elixir ad03436..a43e6fc master -> origin/master bcc92cc..a3d88dc v1.2 -> origin/v1.2 * [new tag] v1.2.1 -> v1.2.1 Switched to a new branch 'v1.2.1' From https://github.com/elixir-lang/elixir * tag v1.2.1 -> FETCH_HEAD Already up-to-date. cd lib/elixir && "/Users/jkain/.kiex/builds/elixir-git/rebar" clean ==> elixir (clean) ... Installed Elixir version 1.2.1 Load with: kiex use 1.2.1 or load the elixir environment file with: source $HOME/.kiex/elixirs/elixir-1.2.1.env
Now that it’s installed I can set up my shell to run it like this:
$ kiex use 1.2.1 Using 1.2.1 $ iex Erlang/OTP 18 [erts-7.2] [source-e6dd627] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] Interactive Elixir (1.2.1) - press Ctrl+C to exit (type h() ENTER for help) iex(1)>
I like to be able to quickly tell which version of Elixir I’m using so I include the version number in my Bash prompt. Kiex is kind enough to set the environment variable
ELIXIR_VERSION. I can use that variable in my prompt like this:
And this is what my prompt looks like:
This was just a brief post to describe how I make use of Kiex and what you can do with it. I hope you’ve found this helpful.