Install Erlang and check the version
OTP is one install: the runtime, the compiler erlc, the script runner escript, the standard library and the OTP applications. Every system packages it, so the install is one command and the version check is the same everywhere. This course was written on OTP 27 and every example was run there.
Install on Linux
On Debian and Ubuntu the APT repositories carry Erlang as the erlang metapackage. Update the package lists and install it:
sudo apt update
sudo apt install erlang
On Rocky Linux and the other RPM systems the package is erlang as well, and dnf installs it with its dependencies. On Alpine Linux, the system of the container this course was checked in, the package manager is Alpine Linux:
sudo dnf install erlang
sudo apk add erlang
These three commands need root and were not run in the container of this course: the container already has the runtime, and it has no network. Each system has a page with the whole install and its own verification, linked below.
One page per system
The Windows installer is an .exe from the Erlang site, the macOS package comes from Homebrew, and FreeBSD builds the port. A Docker image needs no install at all: the official erlang image has the runtime and the shell. Pick the page of your system:
- Install Erlang on Ubuntu
- Install Erlang on Rocky Linux
- Install Erlang on macOS
- Install Erlang on FreeBSD
- Install Erlang on Windows 11
- Erlang in Docker
Check the version
erl -version prints one line with the version of the emulator, the program that runs the bytecode, and exits without a shell. The emulator version belongs to the OTP release: 15.2.7.14 is the erts of OTP 27.
erl -version
Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 15.2.7.14
Plain erl starts the shell instead. The first two lines name the OTP release, the erts version and the scheduler count, and the prompt is ready for an expression:
erl
Erlang/OTP 27 [erts-15.2.7.14] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns] Eshell V15.2.7.14 (press Ctrl+G to abort, type help(). for help) 1>
The shell itself is the subject of the next lesson, erl: the interactive shell. For now it is enough to see the prompt: a number in the version line means the runtime works.
Verify the install
A version line proves that the emulator starts. A program proves the rest: the compiler writes a beam file and the runtime loads and runs it. Save this as version.erl, compile it and start it:
version.erl
-module(version). -export([main/0]). main() -> io:format("OTP release: ~s~n", [erlang:system_info(otp_release)]), io:format("erts version: ~s~n", [erlang:system_info(version)]), io:format("word size: ~p bytes~n", [erlang:system_info(wordsize)]).
erlc version.erl
erl -noshell -eval 'version:main(), halt().'
OTP release: 27 erts version: 15.2.7.14 word size: 8 bytes
erlang:system_info/1 answers with the release as a string, the erts version as a string, and the word size in bytes. word size: 8 is a 64-bit build. If the compile step says erlc: command not found while erl works, the package is split: install the erlang-dev or the whole erlang package.
Keep Erlang updated
To upgrade later, refresh the package lists, upgrade the package and read the version once more. The commands belong to the system: apt on Debian and Ubuntu, dnf on Rocky Linux, apk on Alpine. They need root and are not run here.
sudo apt update
sudo apt install --only-upgrade erlang
sudo apk upgrade erlang
A newer OTP release prints a higher number in both the shell banner and the program above. The course was checked on OTP 27: a feature it uses may be missing on an older release, and a newer one may print a deprecation warning the page does not have.
Questions
A new set of questions in a new order every time. Choose one answer for each, then check.
-
Which command installs Erlang on Debian or Ubuntu?
Answer
sudo apt install erlangThe
erlangpackage pulls in the runtime, the compiler,escriptand the standard libraries. -
Which command prints the emulator version without starting a shell?
Answer
erl -versionerl -versionprints one line and exits; plainerlstarts the interactive shell. -
What is erts?
Answer
The Erlang runtime system, the emulator under BEAM
erts is the runtime system: the emulator, the process scheduler and the memory handling that BEAM code runs on.
-
Which of these does the
erlangmetapackage of Debian bring in?Answer
The runtime,
erlc,escriptand the standard librariesThe metapackage is the whole OTP distribution a course needs, not a single program.
-
What does the
[64-bit]tag in the first line of theerlbanner say?Answer
The emulator is a 64-bit executable
The tag describes the emulator binary itself; the scheduler count appears separately as
[smp:4:4]. -
What shows that the shell is ready for input?
Answer
1>The prompt counts the queries, so the first one is
1>and the next is2>. -
What does this program print?
-module(q1). -export([main/0]). main() -> io:format("~p~n", [erlang:system_info(wordsize)]).Answer
8wordsizeis in bytes, so a 64-bit build answers8. -
What does this program print when no node name was given to
erl?-module(q2). -export([main/0]). main() -> io:format("~p~n", [node()]).Answer
nonode@nohostA node started without
-snameor-nameis not distributed, and its name is the atomnonode@nohost. -
What does this program print on a node of OTP 27?
-module(q3). -export([main/0]). main() -> Release = erlang:system_info(otp_release), io:format("~p~n", [Release =:= "27"]).Answer
trueotp_releaseis the string"27", so the exact comparison with"27"istrue. -
erlworks buterlc: command not foundappears. What is the likely cause?Answer
The runtime is installed without the compiler package
Some systems split the runtime and the compiler; installing the full
erlangpackage bringserlcback.
The version lines on this page were produced with Erlang/OTP 27 (erts-15.2.7.14) on Alpine Linux 3.24.3 (x86_64). The install commands themselves need Debian, Ubuntu, Rocky Linux or Alpine with root and were not run in the container of this course.
Автор статьи: Arthur Isaev