Saturday, November 16, 2024
Google search engine
HomeGuest BlogsInstall Ruby 3 on RHEL 8|CentOS 8|Rocky Linux 8

Install Ruby 3 on RHEL 8|CentOS 8|Rocky Linux 8

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 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: 0:05:43 ago on Mon 21 Aug 2023 09:16:06 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
ruby                                3.1                                    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.1

Proceed with the installation:

....
Transaction Summary
======================================================================================================================================================================================================
Install  10 Packages

Total download size: 5.1 M
Installed size: 16 M
Is this ok [y/N]: y

Once installed, check version:

$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

Option 2) Install Ruby 3 using rbenv

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-70-g4fec76f

Print a list of all Ruby versions that can be installed with rbenv:

$ rbenv install -l
3.0.6
3.1.4
3.2.2
jruby-9.4.3.0
mruby-3.2.0
picoruby-3.0.0
truffleruby-23.0.0
truffleruby+graalvm-23.0.0
Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all / -L' to show all local versions.

Let’s install Ruby 3.2.2:

$ rbenv install 3.2.2
Installing ruby-3.2.2...
Installed ruby-3.2.2 to /home/technixleo/.rbenv/versions/3.2.2

Setting installed Ruby as global version:

rbenv global 3.2.2

Confirm Ruby version:

$ ruby --version

You have successfully installed Ruby on RHEL 8|CentOS 8|Rocky Linux 8.

Similar:

RELATED ARTICLES

Most Popular

Recent Comments