How to Install Ruby on CentOS/RHEL 8
Abstract: 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 th
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.
There are 2 ways of installing Ruby:- Installing Ruby via Appstream Repositories
- Installing Ruby via RVM Manager
We will shed light on how you install Ruby using the above-mentioned methods.
Install Ruby on CentOS 8 via Appstream RepositoryTo 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 @rubyInstall Ruby on CentOS 8
Upon completion, verify the version of Ruby installed by running the command.
$ ruby --versionVerify 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 ManagerOften 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 | bashInstall 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 reloadReload RVM in CentOS 8
Next, install package requirements.
# rvm requirementsInstall 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 knownRVM 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.1Install 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 --versionCheck 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 --defaultSet 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.