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 https://get.rvm.io | 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/rvm.sh

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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

2 Comments

Leave a Reply
  1. Getting below error while installing ruby using rvm in oel8.

    Error running ‘__rvm_make -j2’,
    please read /x/home/jenkins/.rvm/log/1711021883_ruby-2.2.5/make.log

    There has been an error while running make. Halting the installation.

    Please advise on this

    Reply
    • @Masthan,

      Please check log file, which will provide more detailed information about what went wrong during the installation process.

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.