Tutorials  /  Ubuntu

How to Install Ruby on Ubuntu 24.04 Using rbenv, RVM, and APT

Ccentron Redaktion · April 2025 ·7 min read ·Ubuntu, Tutorial

Ruby is a flexible and object-oriented programming language, ideal for projects ranging from small scripts to large-scale web development. With its clean syntax and interpreter-based execution, Ruby offers rapid development capabilities. Ubuntu 24.04 is a great platform for setting up Ruby, thanks to its up-to-date features and compatibility with Ruby tools and frameworks.

This tutorial covers two primary methods for installing Ruby on Ubuntu 24.04: using rbenv and RVM.

Install Ruby with rbenv

rbenv allows you to manage multiple Ruby versions on your system and easily switch between them.

Step 1: Install Required Dependencies

Begin by setting up the dependencies necessary for compiling Ruby using the ruby-build plugin:

Console
$ sudo apt install autoconf patch build-essential rustc libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev libtool uuid-dev

Step 2: Run the rbenv Installer

Download and run the latest rbenv installation script:

Console
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash

Step 3: Update the .bashrc File

Append the rbenv path to your shell configuration file:

Console
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

Step 4: Reload the Shell Configuration

Activate the updated configuration:

Console
$ source ~/.bashrc

Step 5: Verify rbenv Installation

Check if rbenv was successfully installed:

Console
$ rbenv -v

Expected output:

rbenv 1.3.0-9-gefeab7f

Step 6: List Available Ruby Versions

Display the Ruby versions available for installation:

Console
$ rbenv install -l

Example output:

  • 3.1.6
  • 3.2.6
  • 3.3.6
  • jruby-9.4.9.0
  • mruby-3.3.0
  • picoruby-3.0.0
  • truffleruby-24.1.1
  • truffleruby+graalvm-24.1.1

Step 7: Install Ruby with rbenv

Choose and install your preferred version, for instance 3.3.6:

Console
$ rbenv install 3.3.6

The installation process typically takes between 3 to 5 minutes.

Step 8: Set Default Ruby Version

Apply the installed version as the system default:

Console
$ rbenv global 3.3.6

Step 9: Confirm Installed Ruby Version

Ensure Ruby is set up correctly by checking the version:

Console
$ ruby --version

Expected result:

ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]

VM

Matching infrastructure at centron

Ubuntu servers without your own hardware: ccloud³ VMs with full root access from €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Install Ruby with RVM

The Ruby Version Manager (RVM) is a tool for handling multiple Ruby installations on a single server. It allows seamless switching between different Ruby environments.

Step 1: Import RVM GPG Keys

Install the necessary GPG keys:

Console
$ gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Step 2: Install RVM

Download and install RVM with the following command:

Console
$ curl -sSL https://get.rvm.io | bash -s

Step 3: Activate RVM

Load RVM into your shell session:

Console
$ source ~/.rvm/scripts/rvm

Step 4: Install RVM Dependencies

Execute the following command to install all required packages:

Console
$ rvm requirements

Example output:

Installing required packages: autoconf, automake, bison, libffi-dev, libgdbm-dev, libsqlite3-dev, libtool, libyaml-dev, sqlite3, libgmp-dev, libncurses-dev, libreadline-dev, libssl-dev...

Requirements installation successful.

Step 5: Verify RVM Installation

Ensure RVM is correctly installed by running:

Console
$ rvm -v

Sample output:

rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

Step 6: Display Available Ruby Versions

List all Ruby versions that can be installed via RVM:

Console
$ rvm list known

Example list includes:

  • [ruby-]1.8.6[-p420]
  • [ruby-]2.7[.8]
  • [ruby-]3.3[.6]
  • ruby-head

Step 7: Install a Ruby Version

Use RVM to install a specific Ruby release like 3.3.6:

Console
$ rvm install 3.3.6

Step 8: Make the Ruby Version Default

Set your preferred version as default in the system:

Console
$ rvm --default use 3.3.6

Step 9: List Installed Ruby Versions

See all Ruby versions installed through RVM:

Console
$ rvm list

Sample output:

=* ruby-3.3.6 [ x86_64 ]

# => - current

# =* - current && default

# * - default

Install Ruby on Ubuntu 24.04 via APT Package Manager

Although Ruby can be installed using the default APT package manager repositories in Ubuntu, be aware that this method may not provide the most recent version. If you prefer to use APT for simplicity, follow the steps outlined below.

Step 1: Update Package Index

Refresh your server’s local package database to ensure you retrieve the latest available package versions:

Console
$ sudo apt update

Step 2: Install Ruby with APT

Install Ruby from the official Ubuntu repository using the following command:

Console
$ sudo apt install ruby-full

Step 3: Verify Ruby Installation

Ensure Ruby has been successfully installed by checking its version:

Console
$ ruby --version

Expected output:

ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x86_64-linux-gnu]

How to Uninstall Ruby on Ubuntu 24.04

If you need to remove Ruby from your system, you can do so based on the method you used to install it. Below are instructions for uninstalling Ruby using rbenv, RVM, or APT.

Remove Ruby Installed with rbenv

Use the following command to remove a specific Ruby version installed via rbenv. Example below uses version 3.3.6:

Console
$ rbenv uninstall 3.3.6

Remove Ruby Installed with RVM

If you installed Ruby using RVM, use this command to remove version 3.3.6 or any other installed version:

Console
$ rvm remove 3.3.6

Uninstall Ruby Installed via APT

Use APT to remove Ruby if it was installed with the package manager:

Console
$ sudo apt autoremove ruby-full

Conclusion

In this guide, you've learned how to install Ruby on Ubuntu 24.04 using three different methods: rbenv, RVM, and APT. With rbenv and RVM, you gain more flexibility to handle multiple Ruby versions for various development projects.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Ubuntu
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren