How to install Elixir in Manjaro Linux

Published on 2018/03/08 ‚óŹ Last updated on 2018/06

Table of contents

Installation process

Install asdf

I really like using version managers to install different coexisting versions for the dev languages that I use.

I’ve been using asdf the extendable version manager, to install Erlang and Elixir with OTP support, and it’s been great.


Clone the GitHub repository:

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.5.0

Add some lines to your .profile and .bashrc files:

echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.profile
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc

Make changes effective with:

source ~/.profile
exec $SHELL

We add asdf.sh to .profile and not to .bashrc, because it will have the side effect of allowing applications started through dmenu —for i3 users— to have the elixir command available.

This is because stuff in .profile gets loaded when you login into your account, so anything there will be available to commands run through dmenu or desktop icons.

But, stuff in .bashrc gets loaded everytime you open a terminal —so another solution, would be to just start code from the CLI.

Install Erlang and Elixir

Install some needed dependencies for Erlang —we need WxWidgets so we can use :observer.start:

sudo pacman -S base-devel ncurses glu mesa wxgtk libpng libssh unixodbc

For Ubuntu you need these dependencies:

sudo apt install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-dev \
libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev

Finally install Erlang and Elixir:

asdf plugin-add erlang
asdf list-all erlang
asdf install erlang 20.3.7
asdf global erlang 20.3.7

asdf plugin-add elixir
asdf list-all elixir
asdf install elixir 1.6.5-otp-20
asdf global elixir 1.6.5-otp-20

To activate iex REPL history, add this to your .bashrc:

echo -e '\nexport ERL_AFLAGS="-kernel shell_history enabled"' >> ~/.bashrc

If you are using this awesome editor (hint: Visual Studio Code), you should try the ElixirLS extension.

Install Hex

Let’s take on Hex the package manager now:

mix local.hex

You can now print some info about your Elixir stack with:

mix hex.info

You’ll see something along the lines of:

Hex:    0.17.7
Elixir: 1.6.5
OTP:    20.3.7

Built with: Elixir 1.6.4 and OTP 19.3

Install Phoenix

Now let’s install a web framework:

mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

To create a new API only web app, try with this command:

mix phx.new my-app --app my_app --module MyApp --no-brunch --no-html

That’s it!

Links


— lt

Feedback & comments

Get in touch on Twitter

Or by good ol' email at adriandcs@gmail.com