How to Install Elixir on Linux Mint 20 (Ubuntu 20.04 Focal Fossa)

5730
Share:
how-to-install-elixir-on-linux-mint-20-ubuntu-20-04-focal-fossa

In my spare time, I love to try out some programming languages. This time I will share my journey with Elixir. Elixir builds on top of Erlang and shares the same abstractions for building distributed, fault-tolerant applications. Elixir also provides productive tooling and an extensible design. The latter is supported by compile-time meta programming with macros and polymorphism via protocols.

Elixir Features

  • compiles to bytecode for the Erlang Virtual Machine (BEAM)
  • Everything is an expression
  • Erlang functions can be called from Elixir, and vice versa, without run time impact, due to compilation to Erlang bytecode
  • Meta programming allowing direct manipulation of abstract syntax tree (AST)
  • Polymorphism via a mechanism called protocols. Like in Clojure, protocols provide a dynamic dispatch mechanism. However, this is not to be confused with multiple dispatch as Elixir protocols dispatch on a single type.
  • Support for documentation via Python-like docstrings in the Markdown formatting language
  • Shared nothing concurrent programming via message passing (Actor model)
  • Emphasis on recursion and higher-order functions instead of side-effect-based looping
  • Lightweight concurrency utilizing Erlang's mechanisms
  • Railway oriented programming via the with construct
  • Built-in tooling for managing dependencies, code compilation, running tests, formatting code, remote debugging and more
  • Lazy and async collections with streams
  • Pattern matching to promote assertive code
  • Unicode support and UTF-8 strings

Elixir Installation

At my first try, I just run these steps:

$ sudo apt update
$ sudo apt install elixir

But when I want to run Phoenix (a web development framework written in Elixir), I'm experiencing this error:

Compiling 1 file (.yrl)
/usr/lib/erlang/lib/parsetools-2.1.8/include/yeccpre.hrl: no such file or directory
could not compile dependency :gettext, "mix compile" failed. You can recompile this dependency with "mix deps.compile gettext", update it with "mix deps.update gettext" or clean it with "mix deps.clean gettext"

After some quick Goggle search and cannot find the correct solution, I decided to start over and install Elixir from it's official source.

$ wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
$ sudo dpkg -i erlang-solutions_2.0_all.deb

If you're using Linux Mint, you need to edit this file: /etc/apt/sources.list.d/erlang-solutions.list. Change from this:

deb http://binaries.erlang-solutions.com/debian ulyana contrib

to this:

deb http://binaries.erlang-solutions.com/debian focal contrib

Then we can continue with Elixir installation:

$ sudo apt install esl-erlang elixir

Once the download and installation process finished, we can verify our installation:

$ elixir -v
Erlang/OTP 23 [erts-11.1.7] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.11.2 (compiled with Erlang/OTP 23)

If you're seeing similar output as above, congratulations, you've successfully installed Elixir on your Linux Mint 20 (or Ubuntu 20.04 Focal Fossa).

Final Words

I hope that you now know how to install Elixir on Linux Mint 20 or Ubuntu 20.04 Focal Fossa. If you run into any issues or have any feedback feel free to drop a comment below.

Tags Elixir
Share:

0 comment

Leave a reply

Your email address will not be published. Required fields are marked *