CentOS 8
Sponsored Link

Ruby 2.7 : Install2020/12/08

 
Install Ruby 2.7.
[1] Confirm the current enabled version of Ruby and Install it.
[root@dlp ~]#
dnf module list ruby

CentOS Linux 8 - AppStream
Name Stream     Profiles       Summary
ruby 2.5 [d][e] common [d] [i] 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

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

# if other versions are enabled, reset once and switch to the version

[root@dlp ~]#
dnf module reset ruby

[root@dlp ~]#
dnf module enable ruby:2.7
# Install Ruby 2.7

[root@dlp ~]#
dnf module -y install ruby:2.7

Dependencies resolved.
================================================================================
 Package           Arch   Version                               Repo       Size
================================================================================
Upgrading:
 ruby              x86_64 2.7.1-133.module_el8.3.0+429+625e5e4e appstream  88 k
 ruby-libs         x86_64 2.7.1-133.module_el8.3.0+429+625e5e4e appstream 3.2 M
 rubygem-bigdecimal
                   x86_64 2.0.0-133.module_el8.3.0+429+625e5e4e appstream 100 k
 rubygem-io-console
                   x86_64 0.5.6-133.module_el8.3.0+429+625e5e4e appstream  71 k
 rubygem-json      x86_64 2.3.0-133.module_el8.3.0+429+625e5e4e appstream  92 k
 rubygem-openssl   x86_64 2.1.2-133.module_el8.3.0+429+625e5e4e appstream 196 k
 rubygem-psych     x86_64 3.1.0-133.module_el8.3.0+429+625e5e4e appstream  96 k
 rubygem-rdoc      noarch 6.2.1-133.module_el8.3.0+429+625e5e4e appstream 454 k
 rubygems          noarch 3.1.2-133.module_el8.3.0+429+625e5e4e appstream 307 k
Installing dependencies:
 ruby-default-gems noarch 2.7.1-133.module_el8.3.0+429+625e5e4e appstream  73 k
     replacing  rubygem-did_you_mean.noarch 1.2.0-106.module_el8.3.0+571+bab7c6bc
 rubygem-irb       noarch 1.2.3-133.module_el8.3.0+429+625e5e4e appstream 114 k
     replacing  ruby-irb.noarch 2.5.5-106.module_el8.3.0+571+bab7c6bc
Installing weak dependencies:
 rubygem-bundler   noarch 2.1.4-133.module_el8.3.0+429+625e5e4e appstream 387 k
Installing module profiles:
 ruby/common

Transaction Summary
================================================================================
Install  3 Packages
Upgrade  9 Packages
.....
.....

[root@dlp ~]#
ruby -v

ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

# verify to create test script

[root@dlp ~]# cat > ruby_test.rb <<'EOF' 
msg = Class.send(:new, String);
mymsg = msg.send(:new, "Hello Ruby World !\n");
STDOUT.send(:write, mymsg)
EOF 

[root@dlp ~]#
ruby ruby_test.rb

Hello Ruby World !
Matched Content