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

Building RAG with enterprise open source AI infrastructure

One of the most critical gaps in traditional Large Language Models (LLMs) is that they…

19 hours ago

Life at Canonical: Victoria Antipova’s perspective as a new joiner in Product Marketing

Canonical is continuously hiring new talent. Being a remote- first company, Canonical’s new joiners receive…

2 days ago

What is patching automation?

What is patching automation? With increasing numbers of vulnerabilities, there is a growing risk of…

3 days ago

A beginner’s tutorial for your first Machine Learning project using Charmed Kubeflow

Wouldn’t it be wonderful to wake up one day with a desire to explore AI…

4 days ago

Ubuntu brings comprehensive support to Azure Cobalt 100 VMs

Ubuntu and Ubuntu Pro supports Microsoft’s Azure Cobalt 100 Virtual Machines (VMs), powered by their…

4 days ago

Ubuntu Weekly Newsletter Issue 870

Welcome to the Ubuntu Weekly Newsletter, Issue 870 for the week of December 8 –…

5 days ago