CentOS Stream 8
Sponsored Link

Ruby 3.1 : インストール2022/08/10

 
Ruby 3.1 をインストールします。
[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 [d]  An interpreter of object-oriented scripting language
ruby  3.1      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 -y enable ruby:3.1
# Ruby 3.0 インストール

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

Dependencies resolved.
======================================================================================
 Package              Arch    Version                                 Repo        Size
======================================================================================
Installing group/module packages:
 ruby                 x86_64  3.1.2-141.module_el8.7.0+1180+5395fc58  appstream   89 k
Installing dependencies:
 ruby-default-gems    noarch  3.1.2-141.module_el8.7.0+1180+5395fc58  appstream   79 k
 ruby-libs            x86_64  3.1.2-141.module_el8.7.0+1180+5395fc58  appstream  3.3 M
 rubygem-io-console   x86_64  0.5.11-141.module_el8.7.0+1180+5395fc58 appstream   73 k
 rubygem-json         x86_64  2.6.1-141.module_el8.7.0+1180+5395fc58  appstream  100 k
 rubygem-psych        x86_64  4.0.3-141.module_el8.7.0+1180+5395fc58  appstream  100 k
Installing weak dependencies:
 rubygem-bigdecimal   x86_64  3.1.1-141.module_el8.7.0+1180+5395fc58  appstream  114 k
 rubygem-bundler      noarch  2.3.7-141.module_el8.7.0+1180+5395fc58  appstream  449 k
 rubygem-rdoc         noarch  6.4.0-141.module_el8.7.0+1180+5395fc58  appstream  518 k
 rubygems             noarch  3.3.7-141.module_el8.7.0+1180+5395fc58  appstream  320 k
Installing module profiles:
 ruby/common

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

[root@dlp ~]#
ruby -v

ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [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 !
関連コンテンツ