How to Install Ruby on CentOS 8. Ruby is an object-oriented programming language focused on simplicity and productivity. RVM (Ruby Version Manager) is a tool for installing and managing multiple Ruby versions on single operating systems. This tutorial will help you to install RVM on your system. After that install the latest Ruby on CentOS 8. This tutorial will also work with RHEL 8 and Scientific Linux 7.
Step 1 – Prerequsities
First of all, install all the required packages for the Ruby installation on your CentOS 8 system. Use the following command to install the required packages:
sudo dnf install gcc-c++ patch readline readline-devel zlib zlib-devel ibffi-devel \ openssl-devel make bzip2 autoconf automake libtool bison sqlite-devel
Step 2 – Install RVM
We can install RVM using a shell script provided by the core team. Now, install the latest stable version of RVM on your system using the following commands. Before installing packages import GPG key on your machine.
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
After that install the latest stable RVM version on your system using the following command:
curl -L get.rvm.io | bash -s stable
Once the installation finished, run below command to load the RVM environment.
source /etc/profile.d/rvm.sh rvm reload
Step 3 – Verify Dependencies
Verify that all the dependencies are properly installed on your system using the below command. If any missing dependency found the script will automatically install it on your system.
rvm requirements run Checking requirements for centos. Requirements installation successful.
Step 4 – Install Ruby on CentOS 8
Your CentOS 8 machine is ready for the Ruby installation. Find out the available Ruby version for installation using the below command.
rvm list known
Then install the required Ruby version on your system. Here, I am installing Ruby 2.6 on my CentOS 8 system. You can simply replace the version to below command of your choice and install.
rvm install 2.7
Step 5 – Setup Default Ruby Version
First of all, check the currently installed ruby versions on your system. So that we can find which version is using currently by the system and which is set to default.
rvm list =* ruby-2.7.0 [ x86_64 ] # => - current # =* - current && default # * - default
If you have multiple versions of ruby, use the below command to set up the default ruby version to be used by applications.
rvm use 2.7 --default Using /usr/local/rvm/gems/ruby-2.7.0
Step 6 – Verify Active Ruby Version
Using the following command you can check the currently active ruby version.
ruby --version ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]