FreeBSD - メンテナンス・トラブルシュート - ruby - ruby26 → ruby27

クラウディア 
1. 概要
2. バージョンの変更
3. アップグレード
4. 再インストールが必要なモジュール

1. 概要

 本記事を書いているのは、2020年11月30日です。

$ pkg version -vl "<"
ruby-2.6.6_2,1                     <   needs updating (index has 2.7.2_1,1)
 てなことになっております。  「Ruby 2.6.0 Released」によれば、2.6.0 のリリースが、2018年12月25日(おおクリスマス)ってことで。  「Ruby 2.6.4 リリース」によれば、2.6.4 のリリースが、2019年8月28日。  「Ruby 2.7.2 リリース」によれば、2.7.2 のリリースが、2020年10月2日。  「2.7」も「2.7.2」へ至ったので、「ports」の正式版が、「2.7.2」へ移行したということなのでしょうか。

2. バージョンの変更


$ portupgrade -f ruby26 -o lang/ruby27
[Reading data from pkg(8) ... - 472 packages found - done]
$ pkg set -o lang/ruby26:lang/ruby27
Change origin from lang/ruby26 to lang/ruby27 for ruby-2.6.6_2,1? [y/N]: y Enter

3. アップグレード

 ところが・・・。  前回同様、途中でこけちゃいましたな。  「make」は通ったようなのですが、「install」でこけたように見えます。

$ portupgrade -vRr ruby

・・・	略	・・・

Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        ruby: 2.6.6_2,1

Number of packages to be removed: 1

The operation will free 37 MiB.
[1/1] Deinstalling ruby-2.6.6_2,1...
[1/1] Deleting files for ruby-2.6.6_2,1: 100%
[Reading data from pkg(8) ... - 471 packages found - done]
--->  Uninstallation of ruby-2.6.6_2,1 ended at: Mon, 30 Nov 2020 09:44:42 +0900 (consumed 00:00:34)
--->  Installation of lang/ruby27 started at: Mon, 30 Nov 2020 09:44:42 +0900
--->  Installing the new version via the port
===>  Deinstalling for ruby27
===>   ruby27 not installed, skipping
===>  Installing for ruby27-2.7.2_1,1
===>  Checking if ruby27 is already installed
===>   Registering installation for ruby27-2.7.2_1,1 as automatic
Installing ruby27-2.7.2_1,1...
Some of the standard commands are provided as separate ports for ease
of upgrading:

        devel/ruby-gems:                gem - RubyGems package manager
        devel/rubygem-irb:              irb - Interactive Ruby
        devel/rubygem-rake:             rake - Ruby Make
        devel/rubygem-rdoc:             rdoc - Ruby Documentation System
        sysutils/rubygem-bundler:       bundler - Tool that manages gem dependencies for ruby applications

And some of the standard libraries are provided as separate ports
since they require extra dependencies:

        databases/rubygem-dbm:  DBM module
        databases/rubygem-gdbm: GDBM module

Install them as occasion demands.

===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/lib/ruby/2.7/amd64-freebsd11/socket.so

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:
https://www.ruby-lang.org/en/
===>  Cleaning for ruby27-2.7.2_1,1
--->  Removing temporary files and directories
--->  Removing old package'
--->  Installation of lang/ruby27 ended at: Mon, 30 Nov 2020 09:45:13 +0900 (consumed 00:00:31)
--->  Cleaning out obsolete shared libraries
--->  Upgrade of lang/ruby27 ended at: Mon, 30 Nov 2020 09:45:14 +0900 (consumed 00:10:12)
--->  ** Upgrade tasks 1: 1 done, 0 ignored, 0 skipped and 0 failed
--->  Session ended at: Mon, 30 Nov 2020 09:45:14 +0900 (consumed 00:10:19)
Traceback (most recent call last):
        10: from /usr/local/sbin/portupgrade:2380:in `<main>'
         9: from /usr/local/sbin/portupgrade:238:in `main'
         8: from /usr/local/sbin/portupgrade:238:in `new'
         7: from /usr/local/lib/ruby/2.6/optparse.rb:1089:in `initialize'
         6: from /usr/local/sbin/portupgrade:855:in `block in main'
         5: from /usr/local/sbin/portupgrade:519:in `block (2 levels) in main'
         4: from /usr/local/lib/ruby/site_ruby/2.6/pkgtools/pkgdb.rb:1058:in `autofix'
         3: from /usr/local/lib/ruby/site_ruby/2.6/pkgtools/pkgdb.rb:1062:in `autofix!'
         2: from /usr/local/lib/ruby/site_ruby/2.6/pkgtools/pkgtools.rb:516:in `xsudo'
         1: from /usr/local/lib/ruby/site_ruby/2.6/pkgtools/pkgtools.rb:510:in `__sudo'
/usr/local/lib/ruby/site_ruby/2.6/pkgtools/pkgtools.rb:487:in `__system': Command failed [exit code 127]: /usr/local/sbin/pkgdb -aFOQ (CommandFailedError)
 とりあえず、「ruby」自体はいけそうなので、単体で、インストールできるかやってみます。

cd /usr/ports/lang/ruby27
make deinstall clean
make
make install
 ここで、「ruby」の バージョンを見ようとすると

$ ruby --version
ruby: コマンドが見つかりません.
$ ruby27 --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [amd64-freebsd11]
 ふむ、「ruby」のシンボリックリンクがなくなっている。  何か、まずいことが起こりそうな気がします。  後は、ruby2.5 から 2.6 へ移行したときのように地道にアップグレードしていくしかないようです。  ちなみに

pkg version -vl "<"
 に、「ruby」はリストされていません。

4. 再インストールが必要なモジュール

 「/etc/make.conf」は、変更します。

vi /etc/make.conf

DEFAULT_VERSIONS+=ruby=2.6
 があれば、以下に変更。  ない場合は、まるまる追加します。

DEFAULT_VERSIONS+=ruby=2.7
 あとは、動作するときに動かないものを再インストールしていこうと思っています。  今のところ(2020年11月30日)は、ここまで。  その後、「ports」を見ようとしたときに

$ portsdb -Fu
portsdb: コマンドが見つかりません.
 なんじゃこら?と思ったら

/usr/local/sbin/portsdb
 の中身は、「Ruby」のソースで、先頭が

#!/usr/local/bin/ruby26
# -*- ruby -*-
# vim: set sts=2 sw=2 ts=8 et:
#
# Copyright (c) 2000-2004 Akinori MUSHA
# Copyright (c) 2006-2008 Sergey Matveychuk <sem@FreeBSD.org>
# Copyright (c) 2009-2012 Stanislav Sedov <stas@FreeBSD.org>
# Copyright (c) 2012 Bryan Drewery <bdrewery@FreeBSD.org>
 となっておる。  再インストールでいけるかしら?  すると今度は、「ruby-bdb」、うむ、前回と同じだ・・・なので  「ports」のディレクトリを含めて一覧化しておきます。  上から順に再インストールします。

/usr/ports/databases/ruby-bdb
/usr/ports/devel/ruby-gems
/usr/ports/ports-mgmt/portupgrade
 「ruby-bdb」を例にとれば、「DEFAULT_VERSIONS+=ruby=2.6」の状態で

cd /usr/ports/databases/ruby-bdb
make deinstall clean
 「DEFAULT_VERSIONS+=ruby=2.7」の状態で

cd /usr/ports/databases/ruby-bdb
make
make install
 ところが、「ruby-bdb」だけは、「ports」でインストールできなかったので「pkg」で

pkg install ruby26-bdb
 「pkg」には、「ruby27-bdb」ってのがまだないんだな・・・。  他のものは、無事インストールできました。  んでまぁ、結局

$ pkg version -vl "<"
ruby-2.6.6_2,1                     <   needs updating (index has 2.7.2_1,1)
 てなことになっちゃいました。

$ ls /usr/local/bin/ruby*
/usr/local/bin/ruby  /usr/local/bin/ruby26  /usr/local/bin/ruby27
$ ls -la /usr/local/bin/ruby
lrwxr-xr-x 1 root wheel 6 10月  3 10:43 /usr/local/bin/ruby -> ruby26
 とまぁ、「ruby」のシンボリックリンクは、「ruby26」を指しておって、気色悪いのですが・・・、「ruby26」が消せる日まで、この状態にしておくしかないかな・・・(2020年12月1日)。  影響を受けるものが、他にもありました。

/usr/ports/editors/vim
ハイスピードプランJETBOY損保との違い