We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
2018 / 03 / 08
2023 / 12 / 12
Install Elixir in Linux
The easiest way to install Elixir in Linux is through asdf, period.
GitHub for asdf-erlang | GitHub for asdf-elixir
Version managers are great. With them you are able to install multiple
versions of the languages you use.
I’ve been using asdf to install Erlang and Elixir
with OTP support for quite some time now.
Install asdf
Clone and install from the AUR:
cd ~/tmp
git clone https://aur.archlinux.org/asdf-vm.git
cd asdf-vm/
makepkg -si
Add some lines to your .profile
and .bashrc
files:
echo -e '\nexport PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"' >> ~/.profile
echo -e '\n. <(asdf completion bash)' >> ~/.bashrc
Make changes effective immediately with:
source ~/.profile
exec $SHELL
Update asdf
To update to the latest stable version just redo the process above.
Install Erlang and Elixir
Let’s get some dependencies for Erlang —we need WxWidgets
so we can use :observer.start
:
sudo pacman -S base-devel glu libpng libssh mesa ncurses unixodbc wxwidgets-gtk3
For Ubuntu you need these dependencies:
sudo apt install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev \
libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev \
libwxgtk-webview3.0-gtk3-dev
Finally install Erlang and Elixir:
asdf plugin add erlang
asdf list all erlang
KERL_BUILD_DOCS=1 asdf install erlang 27.3.4
asdf set -u erlang 27.3.4
asdf plugin add elixir
asdf list all elixir
asdf install elixir 1.18.3-otp-27
asdf set -u elixir 1.18.3-otp-27
To enable the REPL history in IEx:
echo -e '\nexport ERL_AFLAGS="-kernel shell_history enabled"' >> ~/.bashrc
If using Visual Studio Code try out the ElixirLS extension.
Install Hex
Let’s take on Hex the package manager now:
mix local.hex
You can print some info about your Elixir installation with:
mix hex.info
Install Rebar3
mix local.rebar
Install Phoenix
For completeness’ sake let’s install the latest version of Phoenix:
mix archive.install hex phx_new
# Want to install a specific version?
#
# mix archive.install hex phx_new 1.5.7
# mix archive.install hex phx_new 1.6.0-rc.0
That’s it!
Some useful libraries
-
Joken
A JSON Web Token (JWT) Library.
https://github.com/joken-elixir/joken -
dialyxir
https://github.com/jeremyjh/dialyxir -
bcrypt_elixir
Password hashing for Elixir.
https://github.com/riverrun/bcrypt_elixir -
corsica
CORS configuration for your web app.
https://github.com/whatyouhide/corsica -
earmark
Parse Markdown files.
https://github.com/pragdave/earmark -
decimal
Arbitrary precision decimal arithmetic.
https://github.com/ericmj/decimal -
number
Format number to currency and other goodies.
https://github.com/danielberkompas/number -
tz
Time zone support for Elixir.
https://github.com/mathieuprog/tz