How to Install Ruby on CentOS/RHEL 8

Ruby is a dynamic, multi-purpose, free, and open-source programming language that is usually used for the development of web applications.

It’s a high-level programming language that enjoys a vibrant community of developers who help maintain and continually improve the language for better and more efficient code. Ruby can be used in diverse applications such as data analysis, custom database solutions and prototyping to mention a few.

In this article, you will learn how to install Ruby on CentOS 8 and RHEL 8 Linux.

We will shed light on how you install Ruby using the above-mentioned methods.

Install Ruby on CentOS 8 via Appstream Repository

To install Ruby using the AppStream repo, fire up your terminal and update the system’s packages and repositories by invoking the following dnf command.

$ sudo dnf update

Next, ensure the below-mentioned packages are installed before going ahead with Ruby.

$ sudo dnf install gnupg2 curl tar

Finally, install Ruby from the Appstream repositories.

$ sudo dnf install @ruby
Install Ruby on CentOS 8
Install Ruby on CentOS 8

Upon completion, verify the version of Ruby installed by running the command.

$ ruby --version
Verify Ruby Version in CentOS 8
Verify Ruby Version in CentOS 8

From the output, we can see that we have installed Ruby 2.5.5 on our CentOS 8 system.

Install Ruby on CentOS 8 using the RVM Manager

Often abbreviated as RVM, Ruby Version Manager is a versatile command-line tool and package manager such as dnf that allows you to install and manage multiple Ruby environments.

To install rvm, you need to first download the RVM startup script as the root user. So, switch from the regular to root user and execute the following curl command.

# curl -sSL | bash
Install RVM in CentOS 8
Install RVM in CentOS 8

During the installation of the RVM script, a new group rvm is created. Additionally, you get a notification that the installer no longer adds users to the rvm group automatically. Users need to do this by themselves.

Therefore, once the installation is done, add the regular user to the rvm group as shown.

# usermod -aG rvm tecmint

Next, update the system environment variables by executing the command.

# source /etc/profile.d/

Then reload RVM.

# rvm reload
Reload RVM in CentOS 8
Reload RVM in CentOS 8

Next, install package requirements.

# rvm requirements
Install RVM Requirements in CentOS 8
Install RVM Requirements in CentOS 8

Once you are done with the installation, you can now check the various versions of Ruby that are available for download using the command.

# rvm list known
RVM Available Ruby Versions
RVM Available Ruby Versions

By the time of writing this guide, the latest version of Ruby is 2.7.1.

To install Ruby using the RVM manager run the command.

# rvm install ruby 2.7.1
Install Ruby Using RVM in CentOS 8
Install Ruby Using RVM in CentOS 8

This will take a while. This would be a perfect time to take a coffee break as the rvm installs Ruby 2.7.1.

Once the installation is complete, verify the version of Ruby.

$ ruby --version
Check Ruby Version in CentOS 8
Check Ruby Version in CentOS 8

As seen from the output, the version of Ruby has changed to reflect the latest version which was installed by the RVM manager.

To make the above version the default version for Ruby, run the command.

# rvm use 2.7.1 --default
Set Ruby Default Version in CentOS 8
Set Ruby Default Version in CentOS 8

And that’s how you install Ruby on CentOS 8 and RHEL 8. We hope you will find it quite a breeze installing it on your system. Your feedback is most welcome.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.