Before a Ruby program can run on Ubuntu, the system needs Ruby’s interpreter. Ruby is a programming language, and its interpreter runs Ruby programs.
I’ll show you how to install Ruby with APT and check whether Ubuntu’s package version fits your project.
TL;DR
Install Ruby from Ubuntu’s configured repositories with APT, then check the interpreter with ruby --version.
sudo apt update
sudo apt install ruby-full
ruby --version
Ubuntu’s repositories provide the system package, while a version manager supports projects needing another Ruby release.
What Is Ruby on Ubuntu?
Ruby is a programming language whose interpreter runs Ruby programs, and Rails is a web framework written in Ruby that depends on it.
Ruby’s installation guide notes that distribution packages may not match the newest upstream release. Ubuntu’s package catalogue follows its software sources, so two Ubuntu releases can offer different Ruby versions.
Another supported route is Snap, which Ruby’s installation guide documents alongside APT. Snap offers channels for Ruby minor series, while APT follows Ubuntu’s package repositories.
This procedure uses APT as Ubuntu’s native package workflow. Choose Snap only when its channel model suits your deployment. Installing both package routes can make the shell choose an unexpected ruby executable through PATH.
How to Install Ruby on Ubuntu Step by Step
Run the commands in order. The first refreshes APT’s local package index before the package lookup.
Step 1: Refresh the APT package index
The package index is APT’s local catalogue of packages available from configured repositories.
sudo apt update
APT may ask for your account password to run this administrative action. It refreshes package metadata without installing Ruby or upgrading every package.
Step 2: Install the Ruby package
Install ruby-full from the same configured repositories. APT resolves package dependencies and shows its proposed changes before continuing.
sudo apt install ruby-full
Review the package list and confirm the installation when APT prompts. I leave apt upgrade out of this Ruby procedure because a full system upgrade is a separate maintenance decision.
Step 3: Confirm Ruby is available
Ask the interpreter to print its version to confirm that the shell can find Ruby.
ruby --version
The response begins with ruby followed by a version number. This is the version the shell resolved for the command.
Common Ruby Installation Errors
If the shell cannot find Ruby or the available version does not match the project, check the package result and the command path before installing another runtime.
| Symptom | Check | Next action |
|---|---|---|
| ruby: command not found | Run command -v ruby, then review whether APT completed the ruby-full installation | Finish or repair the package installation, then open a new terminal |
| Ruby version differs from the project requirement | Read the project’s README or .ruby-version file | Select a matching version with a version manager rather than replacing the system runtime |
| rbenv install is unavailable | Run rbenv commands to inspect available subcommands | Install and initialize the ruby-build plugin according to its documentation |
I separate a missing executable from a version mismatch because they need different fixes. Check command -v ruby for the path the shell resolves, and compare ruby --version with the project’s declared requirement.
Which Ruby Version Should You Use?
Choose the package route that matches the project’s version requirement.
- For learning Ruby or running a simple script, compare ruby --version with the task requirement and keep APT if it fits.
- When a project specifies another release, read its version file or setup notes and use a manager such as rbenv with ruby-build.
- When projects need separate releases, select versions per project instead of replacing Ubuntu’s Ruby.
rbenv reads a project’s .ruby-version file and selects an installed version for that directory. Building Ruby from source requires tools and libraries beyond the basic APT package.
If the ruby command is missing after installation, open a new terminal and run ruby --version again. If it still fails, inspect the APT result and confirm that ruby-full completed rather than stopping on an error.
If Ruby prints an unsuitable version, check the project’s version declaration before changing the global runtime. With rbenv, install gems as your user. Its managed Ruby belongs to your account, so these gem installs do not need system-wide privileges.
A missing rbenv install subcommand usually means ruby-build has not been added. Check the manager’s plugin setup before trying the installation command again.
RubyGems is Ruby’s package tool, and Rails is one Ruby application framework distributed as gems. After confirming the right Ruby version, follow the project’s instructions or the official Rails installation guide. The Ubuntu and Debian Gradle installation guide covers another APT-managed developer tool, while the apt and apt-get comparison explains the package command used here.
Conclusion: Choose the Version Your Project Needs
APT installs Ruby from Ubuntu’s repositories, and ruby --version reports the interpreter selected by the shell.
FAQ
These answers cover the package choice and version check.
How do I install Ruby on Ubuntu?
Run sudo apt update, then sudo apt install ruby-full. Confirm the interpreter with ruby --version.
How do I check which Ruby versions are installed?
Run ruby --version to see the version selected by your current shell. With rbenv, run rbenv versions to list versions managed by rbenv.
Can I install Ruby on Rails with this command?
No. ruby-full installs Ruby, while Rails is a separate Ruby framework. Install Rails only after choosing a Ruby version that matches your project.
