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:
Step 2: Next, install required dependencies and libraries for Ruby using the following command:
Step 3: Next, run the shell script file using the below-mentioned command:
Step 4: To start using Rbnev, you will need to update the path environment using the following shell script command:
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.
Step 6: Now, use the following command to install the latest version of Ruby on Ubuntu:
Step 7: To set the installed version of Ruby as a global, execute the following command:
To confirm the latest Ruby version, use the following command.
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:
Step 2: Install required dependencies with the following command-line.
Step 3: Now, install RVM by executing the below-given command:
Step 4: Next, execute the following command to find out the available version on RVM:
As 3.1.2 is the latest version, so execute the following installation command to install the latest version of Ruby on Ubuntu:
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:
Step 2: Then use the below-mentioned command to install Ruby on Ubuntu:
Step 3: After the Ruby installation is completed, you can then check the version using the following command.
Removing Ruby from Ubuntu 22.04 repository
To remove Ruby from Ubuntu 22.04 repository, execute the below-mentioned command.
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.