Installing Elixir 1.2 on a Raspberry Pi
08 Mar 2016I’ve been playing with Elixir off and on over the past couple of months
and wanted a way to run some things using Elixir on my Raspberry Pi.
Sadly, there aren’t any packages for Elixir that are up to date and work
on the Raspberry Pi. Due to the lack of packages, I compiled it from
source. Here’s how I did it. I have both an original Raspberry Pi and a
Raspberry Pi 2 and the instructions below will work with both. We’ll
assume you’re the pi
user on your Raspberry Pi and that you can run
commands as root
using sudo
.
We’ve got to start off building Erlang first, because the packages for Raspbian Jesse are too old to support Elixir 1.2
1. Install the necessary packages so we can build Erlang:
2. Download and extract the Erlang 18.2.1 release from erlang.org:
3. Compile all the Erlang bits. We’ll install Erlang into
/opt/erlang/18.2.1
which is just an arbitrary choice.
Erlang’s install documentation is an excellent resource if you want to dig more into how to build and install Erlang. For example, they recommend building and running the smoke tests for the compiler, but I’ve chosen not to do that here. The above commands come from their docs and do the following:
- Go into the source directory
- Set up a shell variable we’ll use a few steps later
- Build Erlang
- Install the Erlang compiler and runtime into our chosen location.
Now that we have Erlang compiled and installed, it’s time to install Elixir. Fortunately, this process is much easier and much quicker.
1. Download the precompiled release for the Elixir version we want.
2. Create the path we’re going to install Elixir into
3. Extract the Elixir release into its path
The last bit to get everything set up is to add both
/opt/erlang/18.2.1/bin
and /opt/elixir/1.2.3/bin
to your $PATH
. In
my case, I just chose to hack /etc/profile
directly. Due to the myriad
of ways this can be accomplished, I’m leaving this as an exercise to the
user.
Super huge thanks to @wtfleming for their post about doing embedded work on a Raspberry Pi with Elixir. I took a lot of what they wrote and extracted and built upon it while writing this post.