1080*80 ad

Installing Erlang on Ubuntu

How to Install Erlang on Ubuntu: A Step-by-Step Guide for Developers

Erlang is a powerful, open-source programming language and runtime environment designed for building massively scalable, soft real-time systems with high availability. Known for its concurrency, fault tolerance, and distribution capabilities, the Erlang/OTP (Open Telecom Platform) framework is the backbone of robust applications in telecom, banking, and instant messaging. It is also the foundation upon which the popular Elixir programming language is built.

Whether you’re an Elixir developer or exploring concurrent programming, installing Erlang on your Ubuntu system is the first critical step. This guide provides two clear, reliable methods for getting Erlang up and running.

Prerequisites

Before you begin, ensure you have the following:

  • An Ubuntu system (this guide is tested on recent LTS versions like 20.04 and 22.04).
  • Access to a terminal or command-line interface.
  • A user account with sudo or root privileges.

As a best practice, always start by updating your system’s package index:

sudo apt update
sudo apt upgrade

Method 1: Installing from Ubuntu’s Default Repository (The Quick Way)

The simplest way to install Erlang is by using Ubuntu’s default APT repository. This method is fast and straightforward, but it often provides an older, though stable, version of Erlang. If you don’t need the absolute latest features, this is a perfectly acceptable approach.

To install Erlang using APT, run the following command:

sudo apt install erlang

The system will prompt you to confirm the installation and its dependencies. Press Y and hit Enter to proceed. Once the installation is complete, you can verify it.

Method 2: Installing via the Erlang Solutions Repository (Recommended)

For serious development, especially if you plan to use frameworks like Phoenix with Elixir, it is highly recommended to install a recent version of Erlang. The official repositories maintained by Erlang Solutions provide up-to-date packages and are the industry-standard source.

This process involves adding a new repository to your system.

Step 1: Install Required Dependencies

First, ensure you have the necessary packages to manage software repositories over HTTPS.

sudo apt install -y wget gnupg

Step 2: Add the Erlang Solutions GPG Key

Next, you need to download and add the GPG key for the Erlang Solutions repository. This key is used to verify that the packages you are about to download are authentic and have not been tampered with.

wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo gpg --dearmor -o /usr/share/keyrings/erlang_solutions-archive-keyring.gpg

Step 3: Add the Repository to Your System

Now, create a new repository source file. This command automatically detects your Ubuntu version name (e.g., jammy, focal) and adds the correct repository information.

echo "deb [signed-by=/usr/share/keyrings/erlang_solutions-archive-keyring.gpg] https://packages.erlang-solutions.com/ubuntu $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/erlang_solutions.list

Step 4: Update Package Lists and Install Erlang

With the new repository added, you must update your local package index again to fetch the package information from it.

sudo apt update

Finally, install the latest Erlang package. The esl-erlang package is the one provided by Erlang Solutions.

sudo apt install esl-erlang

This will install the complete Erlang/OTP platform with all its libraries and applications.

Verifying Your Erlang Installation

Regardless of the method you chose, the final step is to confirm that Erlang is installed correctly. You can do this by launching the Erlang shell, also known as the REPL (Read-Eval-Print Loop).

Open your terminal and type:

erl

If the installation was successful, you will see a prompt that looks similar to this:

Erlang/OTP 25 [erts-13.1.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Eshell V13.1.3 (abort with ^G)
1>

The output shows the Erlang/OTP version, the Eshell version, and a command prompt 1>.

You can run a simple command to be sure it’s working. Type the following and press Enter:

1> io:fwrite("Hello, world!\n").

The shell should print “Hello, world!” and return ok.

To exit the Erlang shell, type halt(). (including the period) and press Enter, or simply press Ctrl+C twice.

2> halt().

Choosing the Right Method

  • For quick tests or simple projects where the version is not critical, installing from the default Ubuntu repository (Method 1) is sufficient.
  • For professional development, compatibility with Elixir, or access to the latest features and security patches, you should always use the Erlang Solutions repository (Method 2).

By following this guide, you now have a fully functional Erlang environment on your Ubuntu machine, ready for building the next generation of scalable and resilient applications.

Source: https://kifarunix.com/install-erlang-on-ubuntu/

900*80 ad

      1080*80 ad