MacPortsのupgradeでハマったこと

久しぶりに、MacPortsのupgradeを実行して、ハマったところがあったので、メモを兼ねて書いておきます。

makeがない??

まず最初は、初歩的な問題でした。

$ sudo port upgrade outdated
....
Error: Unable to open port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?
....

これは、Xcode 4.3.xをインストールした後に、Command Line Toolのインストール*1をし忘れてたことによります。すぐに気付いて、インストールしてクリアしました。

ncursesがactivateできない??

次は、以下の問題が起きました。

$ sudo port upgrade outdated
....
--->  Activating ncurses @5.9_1 
Error: org.macports.activate for port nurses returned: Image error: /opt/local/bin/captoinfo is being used by the active ncursesw port.  Please deactivate this port first, or use 'port -f activate nurses' to force the activation.
Please see the log file for port nurses for details:
....

何か不整合が起きているために、エラーになったようです。
以下のレポートを参考に、強制的にuninstallしてから、やり直したら、とりあえず、先に進んでくれたようです。

#34872 (Failed to install ncurses) – MacPorts

$ sudo port -f uninstall ncursesw
....
Warning: Deactivate forced.  Proceeding despite dependencies.
--->  Uninstalling ncursesw @5.7_0+darwin_10 

perl5も失敗??

とりあえず、先に進んだのですが、今度はperl5のactivateでもエラーになりました。

$ sudo port upgrade outdated
....
--->  Activating perl5 @5.12.4_0+perl5_12 
Error: org.macports.activate for port perl5 returned: Image error: /opt/local/bin/a2p is being used by the active perl5.8 port.  Please deactivate this port first, or use 'port -f activate perl5' to force the activation.
Error: Failed to install perl5
Please see the log file for port perl5 for details:
....

こちらも、以下のレポートを参考にいくつかのバージョンをuninstallしました。
#28831 (port upgrad outdated fails with error: /opt/local/bin/a2p is being used by the active perl5.8 port.) – MacPorts

$ sudo port installed | grep perl
  p5-libwww-perl @5.834_0 (active)
  perl5 @5.8.9_0
  perl5 @5.12.4_0+perl5_12 
  perl5.8 @5.8.9_3 (active)
  perl5.12 @5.12.4_1 (active)
  subversion-perlbindings @1.6.9_0 (active)

$ sudo port uninstall perl5 @5.8.9_0
--->  Uninstalling perl5 @5.8.9_0 

$ sudo port upgrade perl5.8
....

$ sudo port installed | grep perl
  p5-libwww-perl @5.834_0 (active)
  perl5 @5.12.4_0+perl5_12 
  perl5.8 @5.8.9_3
  perl5.8 @5.8.9_8 (active)
  perl5.12 @5.12.4_1 (active)
  subversion-perlbindings @1.6.9_0 (active)
$ sudo port uninstall perl5.8 @5.8.9_3 
--->  Uninstalling perl5.8 @5.8.9_3 

この後、再実行したら、エラーがなく無事終了しました。

$ sudo port upgrade outdated
....
--->  Updating database of binaries: 100.0%
--->  Scanning binaries for linking errors: 100.0%
--->  No broken files found.


環境によって、ここで説明した方法が当てはまらないこともあるかもしれませんが、もしも、同じような状況になったときに、参考になればと思います。

*1:Command Line Toolのインストールは、PreferenceのツールバーからDownloadボタンをクリックして表示された一覧から、Command Line Toolsの行にあるinstallボタンをクリックします