CentOS Stream 8
Sponsored Link

Ruby 3.0 : インストール2021/09/23

 
Ruby 3.0 をインストールします。
[1] 現在、有効になっている Ruby のバージョンを確認してインストールします。
[root@dlp ~]#
dnf module list ruby

CentOS Stream 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      An interpreter of object-oriented scripting language

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

# 他バージョンが有効な場合は一旦リセットして有効バージョンを切り替え

[root@dlp ~]#
dnf module reset ruby

[root@dlp ~]#
dnf module enable ruby:3.0
# Ruby 3.0 インストール

[root@dlp ~]#
dnf module -y install ruby:3.0/common

Dependencies resolved.
================================================================================
 Package          Arch   Version                                Repo       Size
================================================================================
Installing group/module packages:
 ruby             x86_64 3.0.2-139.module_el8.5.0+916+17ac145a  appstream  89 k
Installing dependencies:
 ruby-libs        x86_64 3.0.2-139.module_el8.5.0+916+17ac145a  appstream 3.2 M
 rubygem-json     x86_64 2.5.1-139.module_el8.5.0+916+17ac145a  appstream 100 k
 rubygem-psych    x86_64 3.3.0-139.module_el8.5.0+916+17ac145a  appstream  99 k
Installing weak dependencies:
 ruby-default-gems
                  noarch 3.0.2-139.module_el8.5.0+916+17ac145a  appstream  80 k
 rubygem-bigdecimal
                  x86_64 3.0.0-139.module_el8.5.0+916+17ac145a  appstream 102 k
 rubygem-bundler  noarch 2.2.22-139.module_el8.5.0+916+17ac145a appstream 444 k
 rubygem-io-console
                  x86_64 0.5.7-139.module_el8.5.0+916+17ac145a  appstream  72 k
 rubygem-rdoc     noarch 6.3.1-139.module_el8.5.0+916+17ac145a  appstream 459 k
 rubygems         noarch 3.2.22-139.module_el8.5.0+916+17ac145a appstream 319 k
Installing module profiles:
 ruby/common

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

[root@dlp ~]#
ruby -v

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]

# テストスクリプトを作成して動作確認

[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 !
関連コンテンツ