Learn how to – 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 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
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.0
Proceed with the installation:
....
Dependencies resolved.
======================================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================================
Installing group/module packages:
ruby x86_64 3.1.2-141.module+el8.7.0+1081+f0a69743 appstream 88 k
Installing dependencies:
ruby-default-gems noarch 3.1.2-141.module+el8.7.0+1081+f0a69743 appstream 78 k
ruby-libs x86_64 3.1.2-141.module+el8.7.0+1081+f0a69743 appstream 3.3 M
rubygem-io-console x86_64 0.5.11-141.module+el8.7.0+1081+f0a69743 appstream 72 k
rubygem-json x86_64 2.6.1-141.module+el8.7.0+1081+f0a69743 appstream 99 k
rubygem-psych x86_64 4.0.3-141.module+el8.7.0+1081+f0a69743 appstream 98 k
Installing weak dependencies:
rubygem-bigdecimal x86_64 3.1.1-141.module+el8.7.0+1081+f0a69743 appstream 113 k
rubygem-bundler noarch 2.3.7-141.module+el8.7.0+1081+f0a69743 appstream 448 k
rubygem-rdoc noarch 6.4.0-141.module+el8.7.0+1081+f0a69743 appstream 517 k
rubygems noarch 3.3.7-141.module+el8.7.0+1081+f0a69743 appstream 319 k
Installing module profiles:
ruby/common
Enabling module streams:
ruby 3.1
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 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-59-g0704e65
Print a list of all Ruby versions that can be installed with rbenv
:
$ rbenv install -l
2.7.7
3.0.5
3.1.3
3.2.1
jruby-9.4.1.0
mruby-3.2.0
picoruby-3.0.0
truffleruby-22.3.1
truffleruby+graalvm-22.3.1
Let’s install Ruby 3.2.1:
$ rbenv install 3.2.1
Installing ruby-3.2.1...
Installed ruby-3.2.1 to /home/technixleo/.rbenv/versions/3.2.1
Setting installed Ruby as global version:
rbenv global 3.2.1
Confirm Ruby version:
$ ruby --version
You have successfully installed Ruby on RHEL 8|CentOS 8|Rocky Linux 8.
Similar:
- Install Python on CentOS / RHEL 8
- Install Node.js on CentOS / RHEL 8
- Install Apache on CentOS/RHEL 8
Leave a Reply
You must be logged in to post a comment.