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

Sponsored
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:

Sponsored
$ 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

Cut data center energy costs with bare metal automation

Data centers are popping up everywhere. With the rapid growth of AI, cloud services, streaming…

18 hours ago

Build the future of *craft: announcing Starcraft Bounties!

Our commitment to building a thriving open source community is stronger than ever. We believe…

18 hours ago

NodeJS 18 LTS EOL extended from April 2025 to May 2032 on Ubuntu

The clock was ticking: Node.js 18’s upstream End of Life (EOL) The OpenJS Foundation is…

18 hours ago

Native integration now available for Pure Storage and Canonical LXD

June 25th, 2025 – Canonical, the company behind Ubuntu, and Pure Storage, the IT pioneer…

2 days ago

Revolutionizing Web Page Creation: How Structured Content is Slashing Design and Development Time

Co-authored with Julie Muzina A year ago, during our Madrid Engineering Sprint, we challenged ourselves…

3 days ago

Ubuntu Weekly Newsletter Issue 897

Welcome to the Ubuntu Weekly Newsletter, Issue 897 for the week of June 15 –…

3 days ago