Categories: Ubuntu

3 Ways to Install Ruby on Ubuntu 22.04

Ruby is an interpreted open-source high-level programming language that is designed to develop front and back-end web applications with the aid of a robust framework called Ruby Rails. The high-level comprehensive syntax structure of Ruby makes you feel like you are coding in English.

This article will provide you with different methods to install Ruby on Ubuntu 22.04.

How to Install Ruby on Ubuntu 22.04

There are three methods to install Ruby on Ubuntu 22.04 which are as following:

  • Using Rbnev
  • Using Ruby Version Manager
  • Using Ubuntu Repository

Method 1: Using Rbnev

Rbnev is a command-line utility that allows you to install the latest version of Ruby on Ubuntu 22.04. It also allows you to run multiple Ruby versions side-by-side.

The following steps are required to install Ruby on Ubuntu 22.04 successfully.

Step 1: First update the Ubuntu apt package system using the following command:

$ sudo apt update

Step 2: Next, install required dependencies and libraries for Ruby using the following command:

$ sudo apt install git curl autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev

Step 3: Next, run the shell script file using the below-mentioned command:

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

Step 4: To start using Rbnev, you will need to update the path environment using the following shell script command:

$ echo ‘export PATH=”$HOME/.rbenv/bin:$PATH”‘ >> ~/.bashrc
echo ‘eval “$(rbenv init -)”‘ >> ~/.bashrc
source ~/.bashrc

Step 5: Once Rbnev installation is completed, you can then list the Ruby version using the following command.

$ rbenv install -l

Step 6: Now, use the following command to install the latest version of Ruby on Ubuntu:

$ rbenv install ruby 3.1.2

Step 7: To set the installed version of Ruby as a global, execute the following command:

$ rbenv global 3.1.2

To confirm the latest Ruby version, use the following command.

$ ruby –version

Method 2 : Using Ruby Version Manager

You can also install Ruby through the built-in Ruby Version Manager (RVM). To perform the installation through this method, use the following steps.

Step 1: Update packages using the following command:

$ sudo apt update

Step 2: Install required dependencies with the following command-line.

$ sudo apt install curl g++ gcc autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev libssl-dev

Step 3: Now, install RVM by executing the below-given command:

$ sudo apt install rvm

Step 4: Next, execute the following command to find out the available version on RVM:

$ rvm list known

As 3.1.2 is the latest version, so execute the following installation command to install the latest version of Ruby on Ubuntu:

$ rvm install ruby 3.1.2

The above command will successfully install Ruby on Ubuntu and you can begin creating different applications with ease by implementing code in Ruby language.

Method 3: Using Ubuntu 22.04 repository

Ubuntu 22.04 repository also includes the Ruby which you can easily install using the following steps. However, it doesn’t install the latest version but still it’s the easiest method to install Ruby on Ubuntu.

Step 1: Update the apt package system using the following command:

$ sudo apt update

Step 2: Then use the below-mentioned command to install Ruby on Ubuntu:

$ sudo apt install ruby-full

Step 3: After the Ruby installation is completed, you can then check the version using the following command.

$ ruby –version

Removing Ruby from Ubuntu 22.04 repository

To remove Ruby from Ubuntu 22.04 repository, execute the below-mentioned command.

$ sudo apt remove –autoremove ruby

Conclusion

Ruby is an open-source and robust programming language used to develop different web applications. There are several methods to install Ruby on Ubuntu 22.04 mentioned in this article. If you want to install the latest version of Ruby, you can pick the Rbnev or RVM method and to ease the installation, you can install Ruby through the apt command.

Ubuntu Server Admin

Recent Posts

Meet the wildlife conservation AI 5G hotspot at MWC Barcelona 2026

From March 2-5 in Barcelona, Canonical will present a working wildlife conservation platform that combines…

21 hours ago

Canonical and Ubuntu RISC-V: a 2025 retro and looking forward to 2026

2025: From RISC-V enablement to real execution  2025 was the year that RISC-V readiness gave…

2 days ago

Unmasking the Resolute Raccoon

You’ve almost certainly seen them… In the forest, rummaging through a dumpster, in poorly aging…

2 days ago

Bad Voltage Season 1 Episode 43: Got The Om On

Jono Bacon, Stuart Langridge and myself present Bad Voltage, in which Bryan is sadly unavoidably…

4 days ago

2011 LinuxQuestions.org Members Choice Award Winners – Thoughts

The polls are closed and the official results are in. You can view the detailed…

4 days ago

Building quantum-safe telecom infrastructure for 5G and beyond

coRAN Labs and Canonical at MWC Barcelona 2026 At MWC Barcelona 2026, coRAN Labs and…

5 days ago