How to Install Erlang on Debian 11

Introduction

Before we begin talking about how to install Erlang on Debian 11, let's briefly understand – What is Erlang?

Erlang is a concurrent programming language developed for building reliable and fault-tolerant systems. Designed by Ericsson, it excels at handling large-scale distributed applications. Erlang's key features include lightweight processes, message-passing between processes, and built-in support for fault detection and recovery.

It enables developers to write highly concurrent and scalable code, making it popular in industries like telecommunications, finance, and gaming. With its robustness and efficiency, Erlang continues to be a powerful tool for creating reliable and fault-tolerant systems.

In this tutorial, you will install Erlang on Debian 11. We will also address a few FAQs on how to install Erlang on Debian 11.

Advantages of Erlang

  1. Concurrency: Erlang's lightweight processes and message-passing allow for efficient concurrency management.
  2. Fault-tolerance: Built-in mechanisms help detect and recover from errors, making Erlang highly reliable.
  3. Scalability: Erlang's design allows for easy horizontal scaling, accommodating growing demands and large-scale distributed systems.
  4. Real-time operations: Erlang's low latency ensures smooth, time-sensitive operations, critical for telecommunication and gaming applications.
  5. Productivity: Erlang's simplicity, pattern matching, and hot code swapping boost developer productivity, leading to faster development and maintenance.

Install Erlang on Debian 11 via APT

Update Debian Before Installing Erlang

Update your Debian system first to make sure all the packages are up-to-date. In order to avoid any conflicts during the installation of Erlang, this step is essential:

sudo apt update && sudo apt upgrade

Install Initial Required Packages for Erlang Installation

For best results, install Erlang from the official Erlang APT repository. Installing the required packages first will make the installation process easier:

sudo apt install dirmngr ca-certificates software-properties-common lsb_release apt-transport-https curl -y

Import Erlang GPG Key and APT Repository

To confirm the legitimacy of the package, import the Erlang GPG key:

curl -fsSL https://packages.erlang-solutions.com/debian/erlang_solutions.asc | sudo gpg --dearmor -o /usr/share/keyrings/erlang.gpg

The Erlang APT repository should then be added to your system:

echo "deb [signed-by=/usr/share/keyrings/erlang.gpg] https://packages.erlang-solutions.com/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/erlang.list
πŸ’‘
Remember that there isn't an official Bookworm build for Debian 12. The distribution version that appears where $(lsb_release -cs) appears is printed by this command. There are only two versions: Bullseye and Buster.

Install Erlang via APT Command on Debian

Reload your APT sources with the most recent Erlang repository added:

sudo apt update

Finally, use the following command to install Erlang:

sudo apt install erlang

This set of instructions guarantees a seamless Erlang installation on Debian 11, adhering to recommended practices for package and system administration. Access to the most recent Erlang versions and upcoming updates is guaranteed by the inclusion of the Erlang repository.

Launch Erlang Shell on Debian 11

Once Erlang has been successfully installed on Debian, run the following command to launch the Erlang shell environment:

erl

Essential Erlang Shell Commands

Several commands in the Erlang shell can improve your productivity and interaction. The following is a list of commonly used commands:

  • q(). – Exits the Erlang shell and runtime.
  • c(file). – Compiles the specified Erlang file. Replace file with your file name.
  • b(). – Shows all variable bindings in the current session.
  • f(). – Clears all variable bindings. Useful for resetting the shell environment.
  • f(X). – Removes the binding of the variable X. Replace X with the variable name.
  • h(). – Displays a history of executed commands in the shell.
  • e(N). – Executes the command located at line number N in the command history.
  • v(N). – Retrieves the return value from the command at line number N.
  • catch_exception(boolean). – Configures error handling strictness in the shell. Replace boolean with true or false.
  • rd(Name, Definition). – Defines a new record type Name with the structure specified by Definition.
  • rr(File). – Creates record types based on definitions in the File.
  • rf(). – Clears all record definitions. You can specify certain definitions to clear.
  • rl(). – Lists all current record definitions in the shell.
  • pwd(). – Outputs the present working directory.
  • ls(). – Lists files in the current directory.
  • cd(Directory). – Changes the shell’s working directory to Directory.

A productive Erlang programming environment is enhanced by these commands, which offer a basic toolkit for interacting with and using the Erlang shell.

Create Hello World Test with Erlang on Debian 11

Crafting a Basic Erlang Program

It is possible to validate your Erlang installation on Debian by writing a basic "Hello World" program. It is customary to test a new programming environment in this manner.

Step 1: Creating the Erlang File

First, open a text editor and begin writing Erlang code. Because of its simplicity, this guide uses Nano:

nano helloworld.erl

Step 2: Writing the Code

Enter this Erlang code in the Nano editor:

-module(helloworld).  % The name of our module.

-export([helloworld/0]).  % Declaration of the function that we want to export from the module.

helloworld() -> io:format("Hello World!! ~n").  % What is to happen when the function is called, here: Hello world is to be written on the screen.

Use CTRL+O to save your work in Nano, ENTER to open it, and CTRL+X to close it.

Step 3: Opening Erlang Shell

Open the Erlang shell in order to compile and execute your program:

erl

Step 4: Compiling the Program

Compile your "Hello World" program in the Erlang shell:

c(helloworld).

Make sure the directory where helloworld.erl is saved and your current directory in the shell match.

Step 5: Running the Program

Run the Erlang program that you have compiled:

helloworld:helloworld().

Step 6: Exiting the Erlang Shell

Use this command to end the Erlang shell after the program has finished running:

q().

Remove (Uninstall) Erlang From Debian

Step 1: Uninstalling Erlang

Should you choose to remove Erlang, run the following command:

sudo apt remove erlang

With this command, the Erlang package is removed from your computer.

Managing Erlang on Debian 11

Update and Upgrade Erlang on Debian

A crucial maintenance task is to update and upgrade the packages on your system on a regular basis. Use these commands to upgrade all installed packages, including Erlang, and to check for updates:

sudo apt update && sudo apt upgrade

This procedure lowers the possibility of software conflicts and security flaws while guaranteeing that your Debian system stays up to date.

Removing the Erlang APT Repository

You can completely uninstall the Erlang APT repository by removing it from your sources list:

sudo rm /etc/apt/sources.list.d/erlang.list

Erlang updates won't be fetched in the future if the repository is removed.

Optional – Removing the GPG Key

You might want to take out the GPG key as well to completely tidy up:

sudo rm /usr/share/keyrings/erlang.gpg

While it's not required, doing this step is advised for users who wish to make sure Erlang is completely removed from their system.

FAQs to Install Erlang on Debian 11

Which version of Erlang is available in Debian 11 repositories?

Debian 11 typically offers the latest stable version of Erlang available at the time of release.

Are there any additional packages that need to be installed alongside Erlang?

No, the basic Erlang package includes all the essential components like the Erlang/OTP platform and standard libraries.

Can I install Erlang via the source code on Debian 11?

Yes, you can install Erlang manually from the official website's source code. However, using the package manager is recommended for easier updates and dependency management.

Does Erlang on Debian 11 support SSL encryption?

Yes, Erlang on Debian 11 supports SSL encryption by default. You can use the ssl module for secure communication.

Can I install additional Erlang libraries or packages on Debian 11?

Yes, you can install additional Erlang libraries using the package manager or by downloading them manually from the official Erlang website.

Is it possible to have multiple versions of Erlang installed on Debian 11 simultaneously?

Yes, it is possible to have multiple versions of Erlang installed on Debian 11. However, careful manual management or the use of version managers is necessary to avoid conflicts between the different versions and ensure proper functioning of each version separately.

Can I install Erlang and Elixir together on Debian 11?

Yes, you can install both Erlang and Elixir, a popular programming language built on top of Erlang, on Debian 11. Install Erlang first and then install Elixir which will automatically use the installed Erlang version.

Conclusion

We hope this tutorial helped you understand how to install Erlang on Debian 11.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.