CentOS

How to Install Ruby on CentOS 8

How to Install Ruby on CentOS 8

Ruby is an open-source and high-level programming language used for developing dynamic and modern web applications. Additionally, Ruby is also used for scripting, data analysis, static site generation and a whole lot more.

Ruby is behind the popular and powerful Ruby and rails framework, upon which many popular websites such as twitter, airbnb, github have been built.

In this guide, we will walk you through the installation of the Ruby programming language on CentOS 8. We will demonstrate two different ways to install Ruby.

Install Ruby from CentOS 8 repositories

First, we need to update our system’s packages and repositories by running the following dnf command.

$ sudo dnf update

Some dependencies are also required for Ruby’s installation to proceed smoothly.

$ sudo dnf install tar curl gnupg2 

With the prerequisites installed, proceed and install Ruby from the CentOS 8 AppStream repositories using the dnf package manager

$ sudo dnf install @ruby

Next, confirm the Ruby version installed as follows:

$ ruby --version

Install Ruby on centOS using RVM

Ruby Version Manager(RVM) is a command-line utility that allows you to easily manage, install and run multiple Ruby environments. To install the latest version of RVM, run the following curl command as a root user.

$ curl -sSL https://get.rvm.io | bash

You will get the output above. During the installation, you will be provided with a source command followed by the path to rvm, use this command to start RVM. In my case, I will run the command:

$ source /home/winnie/ .rvm/scripts/rvm

Next, install ruby package requirements:

$ rvm requirements

Now that ruby package requirements are successfully installed, let’s check the versions of Ruby that are available for download. Execute the command:

$ rvm list known

From the output above, we can see that the latest version of Ruby is 3.0.2. This is at the time of writing this article. With RVM installed, the next step is to install Ruby. Specify the version of Ruby you wish to install after the RVM command.

$ rvm install ruby 3.0.2

Finally, let’s verify the version of Ruby installed in our machine with the command:

$ ruby --version

As shown from the output, the Ruby version has now been updated to reflect the most recent version installed by the RVM manager.

Run the command below to make the recently installed version the default Ruby version on your system:

# rvm use 2.7.1 --default

Conclusion

You can now run ruby applications on your centos 8 machine.

Similar Posts