Installing Erlang on Ubuntu might seem daunting at first, but it’s actually quite straightforward once you know the right approach. Whether you’re a seasoned developer looking to explore functional programming or a newcomer curious about this powerful language, this comprehensive guide will walk you through every step of the installation process.
Erlang has been powering some of the world’s most reliable systems for decades, from telecommunications infrastructure to modern web applications like WhatsApp and Discord. Its fault-tolerant design and concurrent processing capabilities make it an excellent choice for building scalable, distributed systems.
In this guide, we’ll cover multiple installation methods, from the simplest package manager approach to compiling from source code. By the end of this article, you’ll not only have Erlang running on your Ubuntu system but also understand how to manage different versions and troubleshoot common issues.
What is Erlang and Why Use It?
Erlang is a programming language designed for building massively scalable, soft real-time systems with requirements for high availability. Originally developed by Ericsson in the 1980s for telecommunications systems, Erlang has evolved into a general-purpose language that excels in concurrent and distributed programming.
Key features that make Erlang special:
- Fault tolerance: The “let it crash” philosophy means individual process failures don’t bring down the entire system
- Massive concurrency: Can handle millions of lightweight processes simultaneously
- Hot code swapping: Update running code without stopping the system
- Distribution: Built-in support for distributed computing across multiple nodes
- Pattern matching: Elegant syntax for complex data manipulation
Companies like Ericsson, WhatsApp, Discord, and Klarna rely on Erlang for their critical infrastructure. WhatsApp, for instance, handles over 2 billion users with a relatively small engineering team, largely thanks to Erlang’s efficiency.
The language runs on the Erlang Virtual Machine (BEAM), which provides the runtime environment for executing Erlang programs. This VM is what you’ll actually be installing when you install Erlang on your Ubuntu system.
System Requirements and Prerequisites
Before diving into the installation process, let’s ensure your Ubuntu system meets the necessary requirements. Erlang is relatively lightweight and runs well on most modern hardware configurations.
Minimum system requirements:
- Ubuntu 16.04 LTS or newer (Ubuntu 20.04 LTS and 22.04 LTS recommended)
- 1 GB RAM (2 GB or more recommended for development)
- 500 MB free disk space for basic installation
- Internet connection for downloading packages
Recommended setup:
- Ubuntu 22.04 LTS or 24.04 LTS
- 4 GB RAM or more
- SSD storage for better performance
- Multi-core processor for optimal concurrent processing
Essential prerequisites:
You’ll need sudo privileges on your Ubuntu system to install packages. Most installation methods require administrative access, so make sure you can execute commands with sudo
.
Check your Ubuntu version with:
lsb_release -a
Update your system packages before beginning:
sudo apt update && sudo apt upgrade -y
Method 1: Installing Erlang from Ubuntu Repository
The simplest way to install Erlang on Ubuntu is using the default package repository. This method is perfect for beginners or when you need a quick setup without specific version requirements.
Updating the Package List
First, refresh your package manager’s database to ensure you’re getting the latest available versions:
sudo apt update
This command downloads the package information from all configured sources, ensuring you have access to the most recent package versions available in the Ubuntu repositories.
Installing Erlang
Install Erlang with a single command:
sudo apt install erlang
This installs the complete Erlang/OTP system, including:
- The Erlang runtime system
- Standard library modules
- Development tools
- Documentation
The installation typically takes 2-5 minutes depending on your internet connection and system performance. You’ll see various packages being installed, including erlang-base
, erlang-crypto
, erlang-syntax-tools
, and many others.
Advantages of this method:
- Simplicity: One command installation
- Stability: Packages are tested for your Ubuntu version
- Security: Automatic security updates through Ubuntu’s update system
Limitations:
- Older versions: Repository versions often lag behind the latest Erlang releases
- Limited control: You can’t easily install specific versions
Method 2: Installing Erlang from Erlang Solutions Repository
For access to the latest Erlang versions and better control over your installation, using the official Erlang Solutions repository is the preferred method for serious development work.
Adding the Repository Key
First, import the GPG key to verify package authenticity:
wget -O- https://packages.erlang-solutions.com/erlang_solutions.asc | sudo apt-key add -
Alternatively, for newer Ubuntu versions that prefer the modern approach:
wget -O- https://packages.erlang-solutions.com/erlang_solutions.asc | sudo gpg --dearmor -o /usr/share/keyrings/erlang-solutions.gpg
Adding the Repository
Add the Erlang Solutions repository to your system:
For Ubuntu 22.04 (Jammy):
echo "deb [signed-by=/usr/share/keyrings/erlang-solutions.gpg] https://packages.erlang-solutions.com/ubuntu jammy contrib" | sudo tee /etc/apt/sources.list.d/erlang-solutions.list
For Ubuntu 20.04 (Focal):
echo "deb [signed-by=/usr/share/keyrings/erlang-solutions.gpg] https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/erlang-solutions.list
Update the package list:
sudo apt update
Installing Erlang
Now install the latest Erlang version:
sudo apt install erlang
Or install a specific version (if available):
sudo apt install erlang=1:25.3-1
This method typically provides Erlang versions that are 1-6 months newer than the default Ubuntu repository, giving you access to the latest features and performance improvements.
Method 3: Compiling Erlang from Source Code
Compiling from source gives you maximum control over the installation, allowing you to enable specific features, optimize for your hardware, or install the absolute latest version.
Installing Build Dependencies
Install the necessary build tools and libraries:
sudo apt install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev
For SSL support (highly recommended):
sudo apt install libssl-dev
Downloading Source Code
Visit the official Erlang website or GitHub repository to get the latest source code:
cd /tmp
wget https://github.com/erlang/otp/releases/download/OTP-26.1.2/otp_src_26.1.2.tar.gz
tar -xzf otp_src_26.1.2.tar.gz
cd otp_src_26.1.2
Compiling and Installing
Configure the build (this step takes 2-5 minutes):
./configure --enable-ssl --enable-dynamic-ssl-lib
Compile Erlang (this can take 15-45 minutes depending on your system):
make
Install the compiled version:
sudo make install
The compiled version will be installed to /usr/local/bin/
by default.
Benefits of compiling from source:
- Latest features: Access to cutting-edge Erlang features
- Optimization: Compile with flags optimized for your specific hardware
- Custom features: Enable or disable specific components
Considerations:
- Time-consuming: Compilation can take significant time
- Complexity: More steps and potential for errors
- Maintenance: Manual updates required
Method 4: Using ASDF Version Manager
ASDF is a version manager that allows you to install and manage multiple versions of Erlang (and other languages) simultaneously. This is invaluable for developers working on multiple projects requiring different Erlang versions.
Installing ASDF
First, install ASDF dependencies:
sudo apt install curl git
Download and install ASDF:
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1
Add ASDF to your shell profile:
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
Restart your terminal or source your profile:
source ~/.bashrc
Installing Erlang Plugin
Add the Erlang plugin to ASDF:
asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
Install build dependencies for Erlang compilation:
sudo apt install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk
Installing Specific Erlang Versions
List available Erlang versions:
asdf list all erlang
Install a specific version:
asdf install erlang 26.1.2
Set it as your global default:
asdf global erlang 26.1.2
Or set it for a specific project directory:
cd /path/to/your/project
asdf local erlang 26.1.2
Advantages of ASDF:
- Multiple versions: Run different Erlang versions for different projects
- Project-specific versions: Automatically switch versions based on project requirements
- Easy updates: Simple commands to install new versions
- Cross-language: Manage other programming languages with the same tool
Verifying Your Erlang Installation
Regardless of which installation method you chose, it’s crucial to verify that Erlang is properly installed and working correctly.
Check the Erlang version:
erl -version
This should output something like:
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 13.2.2
Start the Erlang shell:
erl
You should see the Erlang shell prompt:
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]
Eshell V14.1.1 (abort with ^G)
1>
Test basic functionality:
In the Erlang shell, try some basic operations:
1> 2 + 3.
5
2> lists:reverse([1, 2, 3, 4]).
[4,3,2,1]
3> halt().
The halt().
command exits the Erlang shell.
Check installation paths:
Find where Erlang is installed:
which erl
This typically returns /usr/bin/erl
for package manager installations or /usr/local/bin/erl
for source installations.
Common Installation Issues and Troubleshooting
Even with careful following of instructions, you might encounter some common issues. Here are the most frequent problems and their solutions:
Permission Errors
Problem: “Permission denied” errors during installation.
Solution: Ensure you’re using sudo
for installation commands:
sudo apt install erlang
If you’re compiling from source and getting permission errors during make install
:
sudo make install
Missing Dependencies
Problem: Build errors when compiling from source, mentioning missing libraries.
Solution: Install the complete set of build dependencies:
sudo apt install build-essential autoconf m4 libncurses5-dev libssl-dev libwxgtk3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils
Version Conflicts
Problem: Multiple Erlang versions causing conflicts.
Solution: Remove old installations before installing new ones:
sudo apt remove erlang
sudo apt autoremove
Then reinstall using your preferred method.
PATH Issues: If you have multiple installations, check your PATH:
echo $PATH
Ensure the correct Erlang installation directory appears first in your PATH.
Managing Multiple Erlang Versions
As your Erlang development journey progresses, you’ll likely need to work with different Erlang versions for various projects. Here are strategies for managing multiple versions effectively:
Using ASDF (Recommended): As covered in Method 4, ASDF provides the cleanest way to manage multiple versions:
# Install multiple versions
asdf install erlang 25.3.2
asdf install erlang 26.1.2
# List installed versions
asdf list erlang
# Switch versions globally
asdf global erlang 26.1.2
# Use different versions per project
cd project1
asdf local erlang 25.3.2
cd ../project2
asdf local erlang 26.1.2
Manual Management: If you prefer manual control, install different versions to separate directories:
# When compiling from source, specify installation prefix
./configure --prefix=/opt/erlang-26.1.2
make && sudo make install
# Create symlinks for easy switching
sudo ln -sf /opt/erlang-26.1.2/bin/erl /usr/local/bin/erl
Docker Approach: For complex projects, consider using Docker containers with specific Erlang versions:
FROM erlang:26.1.2-alpine
WORKDIR /app
COPY . .
Essential Erlang Tools and Libraries
Once you have Erlang installed, familiarize yourself with these essential tools that come with your installation:
Core Development Tools:
- erl: The Erlang shell for interactive development and testing
- erlc: The Erlang compiler for compiling .erl files to .beam files
- dialyzer: Static analysis tool for finding type discrepancies
- observer: Graphical tool for monitoring running Erlang systems
Build Tools:
- rebar3: Modern build tool for Erlang projects (install separately)
- mix: Build tool for Elixir projects (if you plan to use Elixir)
Install rebar3 for project management:
curl -O https://s3.amazonaws.com/rebar3/rebar3
chmod +x rebar3
sudo mv rebar3 /usr/local/bin/
Testing your setup with a simple project:
mkdir my_erlang_project
cd my_erlang_project
rebar3 new app myapp
cd myapp
rebar3 compile
rebar3 shell
Performance Optimization Tips
To get the best performance from your Erlang installation on Ubuntu, consider these optimization strategies:
System-level optimizations:
- Increase file descriptor limits: Erlang applications often need many file descriptors
echo "* soft nofile 65536" | sudo tee -a /etc/security/limits.conf
echo "* hard nofile 65536" | sudo tee -a /etc/security/limits.conf
- Optimize scheduler settings: For multi-core systems
export ERL_FLAGS="+S 4:4 +A 30"
- Memory management: Configure appropriate heap sizes for your applications
% In your Erlang application
{min_heap_size, 46422}
Development environment optimization:
- Use SSD storage: Significantly improves compilation times and application startup
- Allocate adequate RAM: Erlang’s garbage collection benefits from sufficient memory
- Monitor system resources: Use tools like
htop
andiotop
to identify bottlenecks
Erlang VM tuning:
# Example startup flags for production systems
erl +K true +A 30 +P 134217727 +Q 65536 +S 4:4
Security Considerations
Security should be a primary concern when installing and running Erlang applications on Ubuntu:
System Security:
- Keep Erlang updated: Regularly update to the latest versions for security patches
sudo apt update && sudo apt upgrade erlang
- Use SSL/TLS: Always compile with SSL support for secure communications
./configure --enable-ssl --enable-dynamic-ssl-lib
- Network security: Configure firewalls appropriately for Erlang’s distributed features
sudo ufw allow from trusted_ip to any port 4369 # EPMD port
sudo ufw allow from trusted_ip to any port 9100:9155 # Default distributed Erlang range
Application Security:
- Input validation: Always validate external input in Erlang applications
- Process isolation: Leverage Erlang’s process isolation for security boundaries
- Secure coding practices: Follow Erlang security best practices for production applications
Development Security:
- Use secure repositories: Only install packages from trusted sources
- Verify checksums: When downloading source code, verify integrity
- Regular security audits: Use tools like
rebar3 audit
for dependency checking
Best Practices for Erlang Development on Ubuntu
To maximize your productivity and maintain a healthy development environment, follow these best practices:
Development Environment Setup:
- Use version control: Always use Git for your Erlang projects
git init
echo "_build/" >> .gitignore
echo "rebar.lock" >> .gitignore
- Project structure: Follow standard Erlang project layouts
my_project/
├── src/
│ ├── my_project_app.erl
│ └── my_project_sup.erl
├── include/
├── priv/
└── rebar.config
- Documentation: Use EDoc for generating documentation
%% @doc This function does something important.
%% @spec my_function(Arg :: term()) -> {ok, Result} | {error, Reason}.
Code Quality:
- Use dialyzer: Run static analysis regularly
rebar3 dialyzer
- Write tests: Use EUnit and Common Test frameworks
rebar3 eunit
rebar3 ct
- Code formatting: Use consistent formatting (rebar3 format plugin)
Performance Monitoring:
% Use observer for runtime monitoring
observer:start().
Deployment Considerations:
- Release management: Use rebar3 releases for production deployments
rebar3 release
- Hot code loading: Design applications for hot code updates
- Monitoring: Implement proper logging and metrics collection
Frequently Asked Questions
1. What’s the difference between Erlang and Elixir, and do I need both installed?
Erlang and Elixir are both programming languages that run on the same virtual machine (BEAM). Erlang is the original language with a more traditional syntax, while Elixir offers modern syntax inspired by Ruby and additional features like macros. You only need to install Erlang to run both languages, but you’ll need to install Elixir separately if you want to write Elixir code. Many developers install both since they can interoperate seamlessly.
2. Can I install multiple versions of Erlang simultaneously without conflicts?
Yes, absolutely! The best approach is using ASDF version manager, which allows you to install multiple Erlang versions and switch between them easily. You can set different versions for different projects or use a global default. Alternatively, you can compile different versions from source and install them in separate directories, though this requires more manual management.
3. Why does compiling Erlang from source take so long on my system?
Compiling Erlang from source is CPU-intensive because it involves building the entire Erlang/OTP system, including hundreds of modules, libraries, and tools. The process typically takes 15-45 minutes depending on your hardware. Factors that affect compilation time include CPU cores (more cores = faster compilation), available RAM, and storage type (SSD is significantly faster than HDD). You can speed up compilation by using the -j
flag with make: make -j$(nproc)
.
4. How do I know which installation method to choose for my project?
Choose based on your needs: Use the Ubuntu repository for simple, stable installations when you don’t need the latest features. Choose Erlang Solutions repository for access to recent versions with easy installation. Compile from source when you need the absolute latest version, specific compile-time options, or hardware optimizations. Use ASDF when you work on multiple projects requiring different Erlang versions or want maximum flexibility in version management.
5. What should I do if I encounter “command not found” errors after installation?
This typically indicates a PATH issue. First, verify Erlang is actually installed by checking /usr/bin/erl
or /usr/local/bin/erl
. If the file exists, add the directory to your PATH by editing ~/.bashrc
and adding export PATH="/usr/local/bin:$PATH"
(adjust the path as needed). Then reload your shell with source ~/.bashrc
. If you’re using ASDF, ensure you’ve properly added the ASDF initialization to your shell profile and restarted your terminal.