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
Upon completion, verify the version of Ruby installed by running the command.
$ ruby --version
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
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
Next, install package requirements.
# rvm requirements
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
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
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
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
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.