2. メンテナンス・トラブルシュート - ruby - ruby のアップデート

 
2.1 きっかけ
2.2 普通にアップデートしようとしてみたのだ
2.3 記憶をたどってみる
2.4 おさらい

2.1 きっかけ

 また ports のアップグレード中のことです。

> pkg version -vl "<"
vim-7.4.1556                       <   needs updating (index has 7.4.1743)
 と出るもんですから…。  vim のアップグレードが必要だな…と(vim は結構頻繁にアップグレードがありますね)。

2.2 普通にアップデートしようとしてみたのだ


> portupgrade -vRr vim
 すると


		前の方は略しておきますが・・・

install  -m 0644 /usr/ports/lang/ruby22/work/ruby-2.2.4/ext/bigdecimal/sample/*.rb  /usr/ports/lang/ruby22/work/stage/usr/local/share/examples/ruby22/bigdecimal/
====> Compressing man pages (compress-man)
===>  Installing for ruby-2.2.4,1
===>  Checking if ruby already installed
===>   An older version of ruby is already installed (ruby-2.1.8,1)
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of ruby
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** [check-already-installed] Error code 1

Stop in /usr/ports/lang/ruby22.
*** [install] Error code 1

Stop in /usr/ports/lang/ruby22.
*** [extract-depends] Error code 1

Stop in /usr/ports/editors/vim.
*** [stage] Error code 1

Stop in /usr/ports/editors/vim.
** Command failed [exit code 1]: /usr/bin/script -qa /tmp/portupgrade20160416-687-10iocjc env UPGRADE_TOOL=portupgrade UPGRADE_PORT=vim-7.4.1556 UPGRADE_PORT_VER=7.4.1556 make
** Fix the problem and try again.
--->  Build of editors/vim ended at: Sat, 16 Apr 2016 21:46:56 +0900 (consumed 00:15:57)
--->  Upgrade of editors/vim ended at: Sat, 16 Apr 2016 21:46:56 +0900 (consumed 00:15:58)
--->  ** Upgrade tasks 1: 0 done, 0 ignored, 0 skipped and 1 failed
--->  Listing the results (+:done / -:ignored / *:skipped / !:failed)
        ! editors/vim (vim-7.4.1556)    (new compiler error)
--->  Packages processed: 0 done, 0 ignored, 0 skipped and 1 failed
--->  Session ended at: Sat, 16 Apr 2016 21:46:56 +0900 (consumed 00:16:09)
 む、これは、以前に見たような…。デジャブかと思いました (あ、フランス語だから デ・ジャヴ?)。  vim-7.4.1556 は ruby-2.2.4,1 に依存していて ruby-2.2.4,1 をインストールしようとしているんだが ruby-2.1.8,1 があるために …。  ええい、またかい。依存しているならもっと仲良くできないんかい!

> pkg info | grep ruby
ruby-2.1.8,1                   Object-oriented interpreted scripting language
ruby21-bdb-0.6.6_4             Ruby interface to Oracle Berkeley DB revision 2 or later

2.3 記憶をたどってみる

 これは、例の 2.1 を 2.2 にあげるあれかな…と。やってみます。

> whereis ruby21
ruby21: /usr/local/bin/ruby21 /usr/local/man/man1/ruby21.1.gz /usr/ports/lang/ruby21
> whereis ruby22
ruby22: /usr/ports/lang/ruby22
> pkg set -o lang/ruby21:lang/ruby22
Change origin from lang/ruby21 to lang/ruby22 for ruby-2.1.8,1? [y/N]: y

> pkg version -vl "<"
ruby-2.1.8,1                       <   needs updating (index has 2.2.4,1)
vim-7.4.1556                       <   needs updating (index has 7.4.1743)
 うむ。

> portupgrade -vRr vim
--->  Session started at: Sat, 16 Apr 2016 23:09:05 +0900
[Reading data from pkg(8) ... - 225 packages found - done]

		~ 中 略 ~

linking ruby22
Generating RDoc documentation
Parsing sources...
  0% [ 1/903]  /usr/ports/lang/ruby22/work/ruby-2.2.4/doc/ChangeLog-1.8.0
  0% [ 2/903]  /usr/ports/lang/ruby22/work/ruby-2.2.4/doc/ChangeLog-1.9.3

		~ 中 略 ~

 99% [901/903]  vm_method.c
 99% [902/903]  vm_trace.c
100% [903/903]  vsnprintf.c
Generating RI format into /usr/ports/lang/ruby22/work/ruby-2.2.4/.ext/rdoc...

		~ 中 略 ~

http://www.ruby-lang.org/en/
===>  Cleaning for ruby-2.2.4,1
--->  Removing temporary files and directories
--->  Removing old package'
--->  Installation of lang/ruby22 ended at: Sat, 16 Apr 2016 23:27:53 +0900 (consumed 00:01:20)
--->  Cleaning out obsolete shared libraries
--->  Upgrade of lang/ruby22 ended at: Sat, 16 Apr 2016 23:27:54 +0900 (consumed 00:18:35)
--->  ** Upgrade tasks 2: 1 done, 0 ignored, 0 skipped and 0 failed
--->  Upgrade of editors/vim started at: Sat, 16 Apr 2016 23:27:55 +0900
--->  Upgrading 'vim-7.4.1556' to 'vim-7.4.1743' (editors/vim)
--->  Build of editors/vim started at: Sat, 16 Apr 2016 23:27:55 +0900

		~ 中 略 ~

install  -m 0644 /usr/ports/editors/vim/files/vietnamese_viscii.vim /usr/ports/editors/vim/work/stage/usr/local/share/vim/vim74/keymap/
====> Compressing man pages (compress-man)
--->  Build of editors/vim ended at: Sat, 16 Apr 2016 23:30:50 +0900 (consumed 00:02:55)
--->  Updating dependency info
--->  Uninstallation of vim-7.4.1556 started at: Sat, 16 Apr 2016 23:30:50 +0900
--->  Fixing up dependencies before creating a package
--->  Uninstallation of vim-7.4.1556 ended at: Sat, 16 Apr 2016 23:30:50 +0900 (consumed 00:00:00)
** Command failed [exit code 127]: /usr/local/sbin/pkgdb -aFOQ
--->  Skipping 'editors/vim'
--->  Upgrade of editors/vim ended at: Sat, 16 Apr 2016 23:30:50 +0900 (consumed 00:02:55)
--->  ** Upgrade tasks 2: 1 done, 0 ignored, 1 skipped and 0 failed
--->  Session ended at: Sat, 16 Apr 2016 23:30:50 +0900 (consumed 00:21:45)
/usr/local/lib/ruby/site_ruby/2.1/pkgtools/pkgtools.rb:487:in `__system': Command failed [exit code 127]: /usr/local/sbin/pkgdb -aFOQ (CommandFailedError)
        from /usr/local/lib/ruby/site_ruby/2.1/pkgtools/pkgtools.rb:510:in `__sudo'
        from /usr/local/lib/ruby/site_ruby/2.1/pkgtools/pkgtools.rb:516:in `xsudo'
        from /usr/local/lib/ruby/site_ruby/2.1/pkgtools/pkgdb.rb:1062:in `autofix!'
        from /usr/local/lib/ruby/site_ruby/2.1/pkgtools/pkgdb.rb:1058:in `autofix'
        from /usr/local/sbin/portupgrade:519:in `block (2 levels) in main'
        from /usr/local/sbin/portupgrade:855:in `call'
        from /usr/local/sbin/portupgrade:855:in `block in main'
        from /usr/local/lib/ruby/2.1/optparse.rb:880:in `initialize'
        from /usr/local/sbin/portupgrade:238:in `new'
        from /usr/local/sbin/portupgrade:238:in `main'
        from /usr/local/sbin/portupgrade:2380:in `<main>'
 あれ? ruby をアップグレードするところまではうまくいっているように見えたのですが…。

> pkg version -vl "<"
vim-7.4.1556                       <   needs updating (index has 7.4.1743)
 気を取り直して以下をもう一度やってみようとすると

> portsnap fetch
> portsnap update
> portsdb -Fu
> pkg version -v
 portsdb -Fu のところで

> portsdb -Fu
> portsdb: No such file or directory
*** [ports] Error code 1
 portsdb が壊れているようですな…。  おお思い出した。おのれの学習能力のなさを嘆きつつ…。

> cd /usr/ports/ports-mgmt/portupgrade
> make
> make reinstall
> portupgrade -vRr vim
 でうまくインストールできました。

2.4 おさらい

 二度あることはきっと三度あるのでおさらい。  vim のアップグレードで ruby のバージョン違いでアップグレードに失敗した場合は  (例は、2.3 から 2.4 へのアップデート時)

> portmaster -o lang/ruby24 ruby23

===>>> Currently installed version: ruby23-bdb-0.6.6_5
===>>> Port directory: /usr/ports/lang/ruby24

===>>> Gathering distinfo list for installed ports

===>>> Launching 'make checksum' for lang/ruby24 in background
===>>> Gathering dependency list for lang/ruby24 from ports
===>>> Launching child to update pkg-1.10.1 to pkg-1.10.5_1

===>>> ruby23-bdb-0.6.6_5 >> pkg-1.10.1 (1/1)

===>>> Currently installed version: pkg-1.10.1
===>>> Port directory: /usr/ports/ports-mgmt/pkg

===>>> Launching 'make checksum' for ports-mgmt/pkg in background
===>>> Gathering dependency list for ports-mgmt/pkg from ports
===>>> No dependencies for ports-mgmt/pkg

===>>> Continuing initial dependency check for lang/ruby24
===>>> Initial dependency check complete for lang/ruby24


===>>> ruby23-bdb-0.6.6_5 >> (1)

===>>> The following actions will be taken if you choose to proceed:
        Upgrade ruby23-bdb-0.6.6_5 to ruby-2.4.4,1
        Upgrade pkg-1.10.1 to pkg-1.10.5_1

===>>> Proceed? y/n [y]	y Enter

・・・略・・・

 で ruby のバージョンを xx から yy にあげておいて

> portupgrade -v ruby
 でいったん ruby をアップグレードして

> cd /usr/ports/ports-mgmt/portupgrade
> make
> make reinstall
 と portupgrade をインストールしなおして

> portupgrade -vRr vim
 で vim をアップグレードするというのがわたしの手順です。