Install Ruby and check the version
Install on Linux
On Debian and Ubuntu one package is
enough for this course. Update the package list first, then install
Ruby.
Other Linux distributions ship Ruby through their own package
manager, so the command differs but the result is the same.
Update the package list
sudo apt update
Install Ruby
sudo apt install ruby
The package manager may install a slightly older Ruby than the newest release. That is fine for this course: every example works on Ruby 3.0 and newer.
ruby -v
Check what was installed with one short command:
Show the installed Ruby version
ruby -v
Ubuntu 24.04:
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x86_64-linux-gnu]
Debian 12:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux-gnu]
The number depends on the distribution release: Ubuntu 24.04 packages Ruby 3.2, Debian 12 packages 3.1. Both are enough for this course. If the terminal answers command not found, the install step above did not finish.
Version managers
Later you may need several Ruby versions on one machine, for example an old project and a new one side by side. Version managers such as rbenv and rvm install Rubies into your home folder and switch between them per project.
You do not need a manager for this course. When you want one, install it from its own documentation first, then it can list and switch the Rubies it manages.
Your first gem command
Ruby ships with a tool called gem that installs shared libraries. Check that it works alongside Ruby:
Show the installed gem version
gem --version
Ubuntu 24.04:
3.4.20
Debian 12:
3.3.15
Later lessons will use gem to add libraries such as test frameworks. For now the version number alone proves that the toolchain is ready.
Next: irb: the interactive shell
Article author: Arthur Isaev