How To Install Erlang on Fedora 42
Erlang has become an essential programming language for developers working on concurrent, fault-tolerant systems. Whether you’re building a distributed database, a messaging system, or telecommunications software, Erlang provides the robust foundation needed for scalable applications. Fedora 42, with its cutting-edge packages and stability, offers an excellent platform for Erlang development. This guide walks you through various methods to install Erlang on Fedora 42, ensuring you can choose the approach that best fits your specific development needs.
Understanding Erlang and OTP
Before diving into the installation process, it’s important to understand what Erlang is and why it matters. Erlang is a functional programming language designed specifically for building massively scalable, soft real-time systems with high availability requirements. Developed by Ericsson in the late 1980s, it has evolved into a powerful platform for concurrent programming.
When we talk about Erlang, we’re usually referring to Erlang/OTP, where OTP stands for Open Telecom Platform. Despite its telecommunications origins, OTP has grown into a comprehensive development framework that extends far beyond its initial purpose. It provides libraries, design principles, and architectural patterns that simplify the development of robust, fault-tolerant applications.
Key Erlang Features:
- Concurrency-oriented programming with lightweight processes
- Built-in distribution mechanisms for creating distributed systems
- Hot code swapping for updates without service interruption
- Fault tolerance through supervision trees and the “let it crash” philosophy
- Soft real-time capabilities for predictable response times
Erlang’s unique approach to concurrency follows the actor model, where each actor (or process in Erlang terminology) has its own state and communicates with other processes exclusively through message passing. This isolation makes it easier to build systems that can recover from failures without bringing down the entire application.
Prerequisites for Installation
Before installing Erlang on Fedora 42, ensure your system meets the following requirements:
System Requirements:
- A Fedora 42 system (workstation or server)
- Root access or a user with sudo privileges
- Internet connection for downloading packages
- At least 1GB of free disk space (more recommended for development work)
First, update your Fedora 42 system to ensure you have the latest packages:
sudo dnf update -y
Install the basic development tools that may be required for different installation methods:
sudo dnf install -y gcc gcc-c++ make git wget
If you have a previous Erlang installation that you want to replace, it’s a good idea to remove it first to avoid conflicts:
sudo dnf remove erlang erlang-*
Method 1: Installing Erlang via DNF Repository
The simplest way to install Erlang on Fedora 42 is through the official DNF package repository. This method provides a stable, pre-packaged version that integrates well with your system.
Steps to Install Erlang Using DNF
1. First, check which versions of Erlang are available in the repository:
sudo dnf search erlang
2. Install the base Erlang package:
sudo dnf install -y erlang
3. For a complete development environment, install additional Erlang packages:
sudo dnf install -y erlang-asn1 erlang-common_test erlang-compiler erlang-crypto erlang-debugger erlang-dialyzer erlang-diameter erlang-edoc erlang-erl_interface erlang-et erlang-eunit erlang-gs erlang-inets erlang-mnesia erlang-observer erlang-odbc erlang-os_mon erlang-parsetools erlang-public_key erlang-reltool erlang-runtime_tools erlang-snmp erlang-ssh erlang-ssl erlang-syntax_tools erlang-tools erlang-xmerl
4. Verify your installation:
erl -version
This method is recommended for beginners or those who don’t need the latest Erlang features. The DNF package is maintained by the Fedora team and follows their release schedule, which might not include the most recent Erlang version.
Advantages of the DNF Method:
- Simple installation process
- Automatic dependency management
- Easy updates through standard system update mechanisms
- Well-integrated with the Fedora package system
Limitations:
- May not include the latest Erlang release
- Limited control over compilation options
- Package may lag behind official Erlang releases
Method 2: Using Third-Party Repositories
For developers who need more recent versions of Erlang than what’s available in the official Fedora repositories, third-party repositories like PackageCloud provide an excellent alternative.
Installing Erlang from PackageCloud Repository
1. First, install the PackageCloud repository configuration:
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
2. Install Erlang:
sudo dnf install -y erlang
3. Verify the installation:
erl -version
Using Cloudsmith Repository Mirror
An alternative third-party source is the Cloudsmith repository mirror, which is particularly useful when the PackageCloud repository reaches its traffic quotas.
1. Add the Cloudsmith repository:
sudo tee /etc/yum.repos.d/rabbitmq-erlang.repo <
2. Install Erlang:
sudo dnf install -y erlang
3. Verify the installation:
erl -version
Using third-party repositories gives you access to more recent Erlang versions, but be aware that these packages aren’t officially supported by the Fedora project. Always check the repository’s reliability before installation.
Method 3: Building Erlang from Source
For maximum control over your Erlang installation, building from source is the preferred method. This approach allows you to customize compilation options and install the exact version you need.
Building Erlang from Source Code
1. First, install the necessary build dependencies:
sudo dnf install -y gcc gcc-c++ make git wget ncurses-devel openssl-devel java-devel
2. Download the Erlang source code. You can get the latest release from the official website or GitHub:
wget https://github.com/erlang/otp/archive/OTP-25.3.tar.gz
3. Extract the archive:
tar -xzf OTP-25.3.tar.gz
cd otp-OTP-25.3
4. Set the $ERL_TOP
environment variable:
export ERL_TOP=`pwd`
5. Run the configure script:
./configure --prefix=/usr/local
You can add various options to the configure command to customize your build. Some useful options include:
--enable-threads # Enable thread support
--enable-smp-support # Enable SMP support
--enable-kernel-poll # Enable kernel poll support
--enable-hipe # Enable HiPE (High-Performance Erlang)
--without-javac # Skip building Java interface
6. Build Erlang:
make
This process may take 15-30 minutes depending on your system’s performance.
7. Optionally, run the test suite to verify the build:
make release_tests
cd release/tests/test_server
$ERL_TOP/bin/erl -s ts install -s ts smoke_test batch -s init stop
8. Install Erlang:
sudo make install
9. Verify the installation:
erl -version
Building from source gives you complete control over your Erlang installation, ensuring you have exactly the features you need. It’s especially useful for production environments where specific optimizations might be required.
Method 4: Using Version Managers
For developers who work with multiple Erlang versions, tools like kerl and asdf provide a convenient way to manage different installations.
Installing Erlang with kerl
1. First, install kerl:
curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl
chmod a+x kerl
sudo mv kerl /usr/local/bin/
2. List available Erlang releases:
kerl list releases
3. Build a specific Erlang version:
kerl build 25.3 erlang-25.3
4. Install the built version:
kerl install erlang-25.3 ~/erlang/25.3
5. Activate this version:
. ~/erlang/25.3/activate
6. Verify the installation:
erl -version
Installing Erlang with asdf
1. First, install asdf:
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.12.0
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
source ~/.bashrc
2. Add the Erlang plugin:
asdf plugin add erlang
3. Install a specific Erlang version:
asdf install erlang 25.3
4. Set the version to use:
asdf global erlang 25.3
5. Verify the installation:
erl -version
Version managers are particularly useful for developers who need to test their applications against different Erlang versions or work on multiple projects with different version requirements.
Post-Installation Configuration
After installing Erlang, configure your environment to optimize your development experience.
Setting Environment Variables
Add the following to your ~/.bashrc
or ~/.bash_profile
:
export ERL_LIBS=/path/to/your/erlang/libraries
If you built Erlang from source or used a version manager, make sure the Erlang binaries are in your PATH:
export PATH=$PATH:/path/to/erlang/bin
Shell Completions
For better command-line experience, add Erlang shell completions:
# For bash
curl -o ~/.erlang_completion https://raw.githubusercontent.com/erlang/otp/master/lib/stdlib/misc/erlang_completion.bash
echo "source ~/.erlang_completion" >> ~/.bashrc
Editor Integration
Configure your code editor for Erlang development. For VS Code, install the “Erlang” extension:
code --install-extension erlang-ls.erlang-ls
For Emacs, add erlang-mode:
(add-to-list 'load-path "/usr/local/lib/erlang/lib/tools-X.X.X/emacs")
(setq erlang-root-dir "/usr/local/lib/erlang")
(add-to-list 'exec-path "/usr/local/lib/erlang/bin")
(require 'erlang-start')
Verifying and Testing Your Installation
After installation, it’s important to verify that Erlang is working correctly on your Fedora 42 system.
Starting the Erlang Shell
Launch the Erlang shell by typing:
erl
You should see something like:
Erlang/OTP 25 [erts-13.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Eshell V13.1.1 (abort with ^G)
1>
Creating a “Hello World” Program
Let’s create a simple Erlang module to test the installation:
1. Create a file named hello.erl
:
-module(hello).
-export([world/0]).
world() ->
io:format("Hello, World!~n").
2. Compile and run it from the Erlang shell:
1> c(hello).
{ok,hello}
2> hello:world().
Hello, World!
ok
Testing Built-in Tools
Explore some of Erlang’s built-in tools:
1> observer:start(). % Launches the Observer GUI tool
The Observer provides insights into your Erlang system, including process information, memory usage, and application structure.
Installing and Using Erlang Package Manager
Hex is the package manager for the Erlang ecosystem, similar to npm for JavaScript or pip for Python.
Installing Hex
1. Install rebar3 first (Erlang build tool):
curl -O https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3
sudo mv rebar3 /usr/local/bin/
2. Install Hex:
mix local.hex
If you don’t have Mix installed (part of Elixir), you can use rebar3 with Hex:
rebar3 hex install
Using Hex with Projects
Create a new rebar3 project and use Hex dependencies:
mkdir myproject
cd myproject
rebar3 new app name=myapp
Edit the rebar.config
file to add dependencies:
{deps, [
{cowboy, "2.9.0"}
]}.
Then fetch dependencies:
rebar3 get-deps
Working with Erlang Build Tools
Rebar3 is the standard build tool for Erlang projects, providing dependency management, compilation, testing, and more.
Creating a New Project
rebar3 new app name=myapp
This creates a basic application structure with the following files:
src/myapp_app.erl
: Application callback modulesrc/myapp_sup.erl
: Top-level supervisorrebar.config
: Project configurationLICENSE
: License fileREADME.md
: Readme file
Compiling and Testing
Build your project:
rebar3 compile
Run tests:
rebar3 eunit
Release Creation
Create a release for deployment:
rebar3 release
This packages your application with its dependencies and the Erlang runtime, making it easy to deploy to production environments.
Common Installation Issues and Troubleshooting
When installing Erlang on Fedora 42, you might encounter several issues. Here’s how to resolve the most common ones:
Missing Dependencies
If you see errors about missing dependencies during compilation:
sudo dnf install -y gcc gcc-c++ make ncurses-devel openssl-devel java-devel wxGTK3-devel
SSL/TLS Issues
If you encounter SSL-related errors:
./configure --with-ssl=/usr/include/openssl
Path Problems
If erl
command is not found after installation:
which erl
If it doesn’t return a path, add Erlang to your PATH:
export PATH=$PATH:/usr/local/lib/erlang/bin
Compilation Errors
For complex compilation errors, try:
make clean
./configure --disable-hipe
make
Version Conflicts
If you have multiple Erlang versions causing conflicts:
which erl
ls -la $(which erl)
This helps identify which installation is being used. Remove or adjust your PATH to select the correct version.
Performance Tuning for Erlang on Fedora 42
Optimizing Erlang for performance on Fedora 42 can significantly improve your application’s behavior.
SMP Settings
For multi-core systems, adjust the number of schedulers:
erl +S 4:4 # Sets 4 CPU schedulers and 4 I/O schedulers
Memory Allocation
Tune the memory allocators:
erl +MBas 2048 +MBcpu 512 +MBlmbcs 512
These parameters adjust the allocation strategy for binary data, CPU-intensive processes, and large message passing.
Kernel Polling
Enable kernel polling for better I/O performance:
erl +K true
Async Thread Pool
Configure the async thread pool size:
erl +A 128
Include these settings in your application’s start script or as environment variables in your deployment configuration.
Security Considerations
When running Erlang applications on Fedora 42, consider these security aspects:
Cookie File Security
The Erlang distribution cookie controls which nodes can connect to each other. Secure this file:
chmod 400 ~/.erlang.cookie
Network Security
For distributed Erlang applications, use TLS for secure communications:
[{kernel,
[{dist_use_ssl, true},
{dist_tls_opts, [{certfile, "/path/to/cert.pem"},
{keyfile, "/path/to/key.pem"}]}
]}].
Add this to your sys.config
file.
Regular Updates
Keep your Erlang installation updated:
sudo dnf update erlang # For DNF installations
For source installations, rebuild periodically with the latest version.
Uninstalling or Upgrading Erlang
Uninstalling Package-Installed Erlang
sudo dnf remove erlang erlang-*
Removing Source Installations
If you installed from source:
sudo rm -rf /usr/local/lib/erlang
sudo rm /usr/local/bin/erl /usr/local/bin/erlc /usr/local/bin/escript
Upgrading Erlang
For DNF installations:
sudo dnf update erlang
For source installations, download the new version and repeat the build process.
For version manager installations:
# With kerl
kerl build 25.3.1 erlang-25.3.1
kerl install erlang-25.3.1 ~/erlang/25.3.1
. ~/erlang/25.3.1/activate
# With asdf
asdf install erlang 25.3.1
asdf global erlang 25.3.1
Congratulations! You have successfully installed Erlang. Thanks for using this tutorial for installing the Erlang programming language on your Fedora 42 Linux system. For additional help or useful information, we recommend you check the official Erlang website.