Installing Elixir on Ubuntu the easy way!
Tags: Ubuntu, Erlang, Installation, Elixir

I’m porting over my twitch chat bot from ruby to elixir! After using libraries like ruby-build and install-ruby for uh… installing ruby I wanted something just as straight forward for elixir.

I’m using a linux subsystem on windows to make development familiar enough to being on a mac.

From the installation documentation for elixir it lists out several options for version managers with the first one being asdf — as that’s really fun to type (clever naming!) so I thought I’d start there and it turned out to be ace!

Installing ASDF itself

Using their documentation you can configure which method to get hold of it by, git/homebrew/pacman and then which bash you are using, mine looked like this:

Grab your commands here: https://asdf-vm.com/#/core-manage-asdf?id=asdf

Getting asdf to do the hard work

To install elixir you’ll need erlang first. I just wanted the latest one but you can lookup the compatibility table if you need something specific.

The general gist of installing with asdf is:

Find the plugin source from their list https://asdf-vm.com/#/plugins-all

Review the plugins dependencies on their Github README

$ asdf plugin-add <plugin name> <plugin Github repo address>

$ asdf install <plugin name> latest or $ asdf install <plugin name> <version>

or $ asdf list <plugin name> get the version that was installed

get the version that was installed $ asdf global <plugin name> <version> make that version accessible from everywhere

That’s the loop I took with both erlang and elixir to get up and running. Which culminates to:



$ sudo apt-get -y install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk # Taken from the erlang plugin README https://github.com/asdf-vm/asdf-erlang#ubuntu-2004-lts $ sudo apt-get -y install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk

$ asdf install erlang latest

$ asdf global erlang 24.0.2 $ asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git $ asdf install erlang latest$ asdf global erlang 24.0.2

$ asdf install elixir latest

$ asdf global elixir 1.12.2-otp-24 $ asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git $ asdf install elixir latest$ asdf global elixir 1.12.2-otp-24

To test it out:

$ iex

Erlang/OTP 24 [erts-12.0.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit] Interactive Elixir (1.12.1) - press Ctrl+C to exit (type h() ENTER for help)

iex(1)> 1+1

2

Perfect! All ready to go!

Summary

asdf makes this process super simple! I’m looking forward to seeing how it holds up over time and with multiple versions, let me know how you found it.

I’ll be making many Elixir guides with a sprinkling of JS and CSS over the course of building my twitch chat bot, so click on the follow button if you want to keep up with everything I’m learning as an Elixir beginner.

Short guides like this help my colander brain not have to remember things XD

We make lots of fun of my memory over on my Twitch channel if you wanted to catch a coding or gaming stream!

TTFN