A step-by-step guide to installing the Elixir programming language with version manager asdf. Asdf is also handy for installing and managing Erlang, as well as for managing other languages and databases. Here’s how to easily obtain Elixir and Erlang and set them up on your Mac.

Want to install Elixir and/or install and manage Erlang? Our article today is a concise guide to performing these tasks on OS X. It’s Elixir 101 installation in a nutshell.

Erlang is a general-purpose, functional programming language and also a runtime system. Elixir is known as a dynamic, functional language designed for building scalable and maintainable applications. Elixir leverages Erlang and builds on top of it. Conveniently, for both of these programming languages, you can use a single version manager for both: asdf. With this tool, you are able to install and manage different versions of Erlang and Elixir. Additionally, asdf can be used for managing other languages, e.g. Ruby or Python, platforms such as Node.js, or even databases like Postgres or Redis. It is a highly versatile tool, so be sure to check it out!

Elixir installation guide

Let’s go through the process of installing asdf step by step.

  1. Before you proceed, make sure you have all the dependencies necessary for asdf (like automake, autoconf, openssl, libyaml, readline, libxslt, libtool and unixodbc), so it can build binaries. On OS X:
    brew install automake autoconf openssl libyaml readline libxslt libtool unixodbc
    
  2. Install asdf:
    git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.3.0
    
  3. Install erlang-plugin:
    asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git
    
  4. Install elixir-plugin:
    asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
    
  5. Install the latest version of Erlang:
    asdf install erlang 19.3
    
  6. Install the latest version of Elixir:
    asdf install elixir 1.4.5
    
  7. Set default global versions of Erlang and Elixir:
    asdf global erlang 19.3
    asdf global elixir 1.4.5
    

Editors

Once you install Elixir, you can choose additional extensions or solutions. Here are a few examples of popular text editors you can choose from to work with Elixir:

  • SublimeText: for SublimeText check out ElixirSublime
  • Atom: for Atom you can use atom-elixir.
  • Vim: for Vim you can use the alchemist.vim plugin with deoplete as the completion engine. Here is an example configuration for this:
    let g:deoplete#enableatstartup = 1
    " Increase cache for large ctags files
    let deoplete#tag#cachelimitsize = 5000000
    let g:deoplete#sources = {}
    " By default suggest from all buffers and tag files
    let g:deoplete#sources._ = ['buffer', 'tag']
    let g:deoplete#sources.elixir = ['alchemist']
    

No matter which editor you use, when you open the project and start typing (i.e. Enum. ), the popup with suggestions should appear.

Sidenote

With rbenv compatible managers - exenv and erlenv, there is no erlang-build plugin for erlenv. This means Erlang has to be built manually.

Once you’ve set up Elixir, you can find a starter guide to Elixir, read up about functional programming for beginners, or be on the look out for our upcoming software house Elixir tutorial in future blog posts.

Want to supercharge your Elixir web development? Augment your team with our Elixir experts and set your project on course for a swift, smooth turnaround. Contact us at iRonin for more info.