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:

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

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

The biggest use cases for AI in Automotive (that aren’t just self-driving cars)

A study of 4 major use cases of AI in cars In this fast-paced age…

20 hours ago

What’s New in Ubuntu 24.04 LTS for Microsoft/Azure Users

Canonical recently announced the release of Ubuntu 24.04 LTS, codenamed “Noble Numbat”. This update underscores…

20 hours ago

Ubuntu Weekly Newsletter Issue 837

Welcome to the Ubuntu Weekly Newsletter, Issue 837 for the week of April 21 –…

1 day ago

Kubernetes backups just got easier with the CloudCasa charm from Catalogic

Kubernetes is very straightforward for deploying and managing stateless applications. Consequently, proper backups of the…

2 days ago

Review of freshly installed Ubuntu Desktop 24.04 LTS (Gnome GUI)

After the article of Ubuntu Desktop 24.04 LTS installation steps Install Ubuntu Desktop 24.04 LTS…

2 days ago

Install Ubuntu Desktop 24.04 LTS on the entire disk with dual boot MS Windows

This article will show the simple steps of installing the latest version of Ubuntu –…

4 days ago