DEV Community

Cover image for Complete Guide: Installing Elixir on Ubuntu/Linux 24.04
João Paulo Abreu
João Paulo Abreu

Posted on • Edited on

Complete Guide: Installing Elixir on Ubuntu/Linux 24.04

Introduction

In this guide, we'll learn how to install Elixir on Ubuntu 24.04. Elixir is a functional and concurrent programming language, ideal for developing distributed applications.

There are two main methods for installing Elixir on Ubuntu: using the apt package manager or using asdf, a multiple version manager. I personally use asdf, but I'll show both methods so you can choose what best suits your needs.

Method 1: Installing Elixir with apt

To install Elixir using Ubuntu's package manager called apt, you can type the following command in the terminal:

sudo apt-get update
sudo apt-get install elixir erlang erlang-doc
Enter fullscreen mode Exit fullscreen mode
  • elixir: This package installs the Elixir compiler and basic tools needed to develop with Elixir.
  • erlang: This package installs the Erlang virtual machine (BEAM) and the necessary components to run Elixir applications.
  • erlang-doc: This package contains Erlang documentation, which can be useful for reference during development.

Using VS Code with Elixir

As a code editor, you can use VS Code with the ElixirLS extension, which is a language server that enables autocompletion and other functions. You can find it on the Visual Studio Code Marketplace.

Method 2: Installing asdf on Ubuntu

In my specific case, I use asdf, which is a multiple version manager, making it easier to have multiple versions of Elixir and Erlang installed on my machine and switch between them for each project.

You can find more information about asdf at the following address: asdf-vm.com. One of the advantages of asdf is that you can have a single installation manager supporting multiple languages.

Installing asdf on Ubuntu

Step 1: Install Dependencies

First, install two dependencies:

sudo apt install curl git
Enter fullscreen mode Exit fullscreen mode

Step 2: Clone the asdf repository

Next, run the following git command in your terminal to install asdf:

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
Enter fullscreen mode Exit fullscreen mode

Step 3: Zsh Configuration

For those using Zsh as their shell, the following configuration should be made in the .zshrc file by adding the line below:

. "$HOME/.asdf/asdf.sh"
Enter fullscreen mode Exit fullscreen mode

Step 4: Install Additional Dependencies

Now, to install asdf plugins for each language on Ubuntu, you need to install some dependencies:

sudo apt install dirmngr gpg curl gawk
Enter fullscreen mode Exit fullscreen mode

Plugins I use with asdf:

Node.js

To add the Node.js plugin:

asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
Enter fullscreen mode Exit fullscreen mode

To list available versions for installation:

asdf list-all nodejs
Enter fullscreen mode Exit fullscreen mode

Installing a specific version:

asdf install nodejs 20.15.0
Enter fullscreen mode Exit fullscreen mode

Setting the global version:

asdf global nodejs 20.15.0
Enter fullscreen mode Exit fullscreen mode

Erlang

Erlang is necessary to have the virtual machine where Elixir will run.

To add the Erlang plugin:

asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
Enter fullscreen mode Exit fullscreen mode

Install dependencies for Ubuntu (link for more information):

sudo apt install build-essential autoconf m4 libncurses5-dev libwxgtk3.2-dev libwxgtk-webview3.2-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk
Enter fullscreen mode Exit fullscreen mode

Installing a specific version:

asdf install erlang 27.0
Enter fullscreen mode Exit fullscreen mode

Setting the global version:

asdf global erlang 27.0
Enter fullscreen mode Exit fullscreen mode

Elixir

To add the Elixir plugin:

asdf plugin add elixir https://github.com/asdf-vm/asdf-elixir.git
Enter fullscreen mode Exit fullscreen mode

Installing a specific version:

asdf install elixir 1.17.1
Enter fullscreen mode Exit fullscreen mode

Setting the global version:

asdf global elixir 1.17.1
Enter fullscreen mode Exit fullscreen mode

Verifying Installations

Now you can open a new terminal and run the following commands to verify if they are installed correctly:

node --version
elixir --version
Enter fullscreen mode Exit fullscreen mode

Now you're ready to start your journey into the world of Elixir! With all the necessary tools installed, you can explore the powerful features of this amazing language. Don't hesitate to experiment, explore, and create incredible projects. Good luck and have fun learning Elixir!

Top comments (0)