In this guide, we will look at how you can Install Ruby 3 on RHEL 8 / CentOS 8 / Rocky Linux 8 system. Ruby is a dynamic, open source, object-oriented scripting language created with simplicity and productivity in mind. In this guide, I’ll show you how to Install Ruby 3 on RHEL 8 / CentOS 8 / Rocky Linux 8 with RVM Ruby Version Manager.
Option 1) Install Ruby 3 on RHEL 8|CentOS 8|Rocky Linux 8 from Repo
RHEL 8 provides Ruby 2 and 3 in AppStream repository. You can confirm its availability using the command:
$ sudo yum module list ruby
Last metadata expiration check: 2:29:55 ago on Thu 05 May 2022 11:52:58 AM UTC.
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
ruby 2.5 [d] common [d] An interpreter of object-oriented scripting language
ruby 2.6 common [d] An interpreter of object-oriented scripting language
ruby 2.7 common [d] An interpreter of object-oriented scripting language
ruby 3.0 common [d] An interpreter of object-oriented scripting language
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Disable default Ruby AppStream module on your system
sudo dnf module reset ruby -y
To specify the module version, use the command:
sudo yum install @ruby:3.0
Proceed with the installation:
Dependencies resolved.
================================================================================================================================================================================================
Package Architecture Version Repository Size
================================================================================================================================================================================================
Installing group/module packages:
ruby x86_64 3.0.2-140.module+el8.5.0+668+665814fa appstream 88 k
Installing dependencies:
ruby-libs x86_64 3.0.2-140.module+el8.5.0+668+665814fa appstream 3.2 M
rubygem-io-console x86_64 0.5.7-140.module+el8.5.0+668+665814fa appstream 72 k
rubygem-json x86_64 2.5.1-140.module+el8.5.0+668+665814fa appstream 99 k
rubygem-psych x86_64 3.3.0-140.module+el8.5.0+668+665814fa appstream 98 k
Installing weak dependencies:
ruby-default-gems noarch 3.0.2-140.module+el8.5.0+668+665814fa appstream 79 k
rubygem-bigdecimal x86_64 3.0.0-140.module+el8.5.0+668+665814fa appstream 101 k
rubygem-bundler noarch 2.2.22-140.module+el8.5.0+668+665814fa appstream 443 k
rubygem-rdoc noarch 6.3.1-140.module+el8.5.0+668+665814fa appstream 458 k
rubygems noarch 3.2.22-140.module+el8.5.0+668+665814fa appstream 318 k
Installing module profiles:
ruby/common
Enabling module streams:
ruby 3.0
Transaction Summary
================================================================================================================================================================================================
Install 10 Packages
Total download size: 5.0 M
Installed size: 16 M
Is this ok [y/N]: y
Once installed, check version:
$ ruby --version
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
Option 2) Install Ruby 3 using rbenv on RHEL 8|CentOS 8|Rocky Linux 8
Rbenv is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. Install RVM on RHEL 8 by running the commands below in your terminal.
Install common tools required
sudo dnf -y install git make gcc curl openssl-devel zlib-devel libffi-devel readline-devel sqlite-devel
Install required rbenv tool by running the following commands:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
Configure environment for Rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
Confirm rbenv version
$ rbenv -v
rbenv 1.2.0-14-gc6cc0a1
Print a list of all Ruby versions that can be installed with rbenv
:
$ rbenv install -l
2.6.10
2.7.6
3.0.4
3.1.2
jruby-9.3.4.0
mruby-3.0.0
rbx-5.0
truffleruby-22.1.0
truffleruby+graalvm-22.1.0
Let’s install Ruby 3.1.2:
$ rbenv install 3.1.2
Installing ruby-3.1.2...
Installed ruby-3.1.2 to /home/technixleo/.rbenv/versions/3.1.2
Setting installed Ruby as global version:
rbenv global 3.1.2
Confirm Ruby version:
$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
You have successfully installed Ruby on RHEL 8|CentOS 8|Rocky Linux 8.