To install Elixir on Ubuntu 26.04 or 24.04, use the official installer to set up Elixir 1.20.5 and Erlang/OTP 29.1 for your account. Ubuntu’s APT packages are a simpler option for learning the basics with the versions your release ships.
Elixir is a programming language that runs on the Erlang virtual machine, known as the BEAM. Erlang/OTP provides that runtime and libraries for tasks such as running concurrent processes. This guide takes you from checking the runtime to writing and testing a small Elixir function.
Before you begin
Use a Bash terminal on Ubuntu 26.04 LTS or 24.04 LTS. The official installation route below covers x86-64 and ARM64. You’ll need internet access and sudo for the system packages. Run the installer and Mix commands as your regular user.
The installer extracts a .tar.gz for Erlang/OTP and a .zip for Elixir. Install unzip up front, especially on minimal servers. Without it, the current script falls back to extracting the ZIP with Erlang after OTP is installed.
1. Install Elixir and Erlang with the Official Script
Step 1. Install the matching toolchain
Run this in a fresh working directory so there is no existing install.sh to overwrite. The download and install must both succeed before the last command removes the script.
Both runtimes go under ~/.elixir-install/installs/. Elixir’s build is matched to the Erlang/OTP major version.
Step 2. Keep both tools on your Bash PATH
Open ~/.bashrc in your text editor. Paste both exact export PATH= lines printed at the end of your installer run, in the same order. The output for the pinned versions looks like this:
Keep the folder names the script actually prints. If a later installation uses a patch directory such as 29.1.x, use that exact path. Replace old Elixir installer entries instead of stacking multiple pairs. Save the file and load it:
Ubuntu terminal
source ~/.bashrc
Step 3. Check both versions
Ubuntu terminal
elixir --version
Look for Erlang/OTP 29 in the first line and Elixir 1.20.5, compiled with OTP 29, in the last line. The OTP banner shows the major release. To check the full release for this installer setup, read the active runtime’s OTP_VERSION file:
Choose APT if its versions meet your needs. The elixir package is in Ubuntu’s Universe repository on both releases. Elixir 1.20 introduces broader gradual type checking and requires OTP 27 or newer within its supported range of OTP 27 through 29.
Ubuntu release
APT Elixir
APT Erlang/OTP
26.04 LTS
1.18.3
27
24.04 LTS
1.14.0
25
Step 1. Install the server-friendly packages
Use erlang-nox for the non-X Erlang applications and erlang-dev for development headers. Skip APT if you already chose the official installer. On a shared server, review the proposed changes if an Erlang application such as RabbitMQ already runs there.
If APT cannot locate elixir, check that Universe is enabled for your Ubuntu release. Then rerun the install command.
Step 2. Verify the system installation
Ubuntu terminal
elixir --version
Compare the output to the table. If it shows the versions from your home directory, remove the installer’s two PATH entries from ~/.bashrc and open a new shell.
For different versions across projects, use mise on Ubuntu to pin Elixir and Erlang per project. This can help if you also work with Gleam on Ubuntu and need a separate OTP version.
3. Try IEx and Build a Mix Project
Step 1. Try a line of Elixir in IEx
IEx is Elixir’s interactive shell. Start it from Bash:
Ubuntu terminal
iex
At the iex> prompt, enter this expression:
IEx expression
Enum.sum([7, 12, 3])
IEx returns 22. At the idle prompt, press Ctrl+C twice to leave IEx and return to Bash.
Step 2. Set up Mix package tools and create a project
Mix comes with Elixir. Hex fetches packages and Rebar3 builds Erlang dependencies when a project needs them. These commands install both for your account. The local example itself has no third-party dependencies, so you can skip this bootstrap if you are offline.
Ubuntu terminal
mix local.hex --force && mix local.rebar --force
From a workspace with no existing order_total directory, create a Mix project using a snake_case name:
Ubuntu terminal
mix new order_total && cd order_total
Step 3. Write and run a function
Replace the generated sample in lib/order_total.ex with the module below. total_cents/1 adds item prices stored as whole cents, keeping the example free of floating-point rounding.
lib/order_total.ex
defmodule OrderTotal do
def total_cents(prices), do: Enum.sum(prices)
end
Ubuntu terminal
mix run -e 'IO.puts(OrderTotal.total_cents([725, 1200, 300]))'
The last line prints 2225, or $22.25.
Step 4. Test with ExUnit
Replace test/order_total_test.exs with these two tests. Keep the generated test/test_helper.exs, which starts ExUnit.
test/order_total_test.exs
defmodule OrderTotalTest do
use ExUnit.Case, async: true
test "adds item prices in cents" do
assert OrderTotal.total_cents([725, 1200, 300]) == 2225
end
test "returns zero for an empty order" do
assert OrderTotal.total_cents([]) == 0
end
end
Issue 1. Elixir is missing or reports the wrong OTP version
Ubuntu terminal
which -a erl elixir
elixir --version
The first match for each command should come from the same installation method. For the official script, both should be under ~/.elixir-install/installs/. For APT, expect Ubuntu’s executables under /usr/bin. Avoid mixing the APT and script toolchains in the same shell. Check the two exports, open a fresh terminal, and check again. For an active mise project, check its configured pair as well.
Issue 2. Mix requests a newer Elixir version
Check the project’s elixir: requirement in mix.exs and any documented OTP requirement. Use a supported Elixir/OTP pair for the project. If you recently switched Elixir or OTP and an existing project still loads old compiled files, run the following from that project before rebuilding.
Ubuntu terminal
mix clean && mix test
5. Update or Remove Elixir and Erlang
Update the official installation
Select a compatible Elixir and OTP pair from the official installation guide. Rerun the download and install step with those versions, then replace both old exports with the new lines the installer prints. Open a fresh Bash session, check elixir --version, refresh Hex and Rebar with the command above if you use them, and rerun your project tests before deleting older versions.
APT updates these packages within your configured repositories. Check the versions after the update.
Remove the official installation
Delete the two installer PATH lines from ~/.bashrc and open a fresh shell. The command below permanently deletes the installer’s runtimes plus the default Mix and Hex directories. Back up anything you need first. Mix and Hex directories can hold shared archives, configuration and credentials for other Elixir or Gleam projects. To keep those settings, remove only ~/.elixir-install.
Ubuntu terminal
rm -rf ~/.elixir-install ~/.mix ~/.hex
Remove the APT installation
Preview the purge first, especially on a machine with other BEAM software. Run the second command only if the proposed changes are safe. APT leaves personal project files and user configuration in place.
Yes. The script installs the selected Erlang/OTP release alongside Elixir. Ubuntu’s Elixir package also pulls in the Erlang components it depends on.
Can I use Ubuntu 24.04’s stock Erlang with Elixir 1.20?
Ubuntu 24.04 ships OTP 25. Elixir 1.20 supports OTP 27, 28 and 29. Use the paired installer or a version manager if your project needs Elixir 1.20.
Do I need Hex and Rebar3 for every project?
A project with no external dependencies can run without either. Hex fetches packages, and Mix uses Rebar3 when it encounters Erlang dependencies that build with Rebar.