過去 El CapitanUpgradeした際、brew install問題が発生した際、記録として、El Capitan で brew install したら、Error: undefined method `<’ for nil:NilClass が発生。 | Monotalk作成しました。
上記文書の読み返し、追記をした際、文章に記載していたbrew/Troubleshooting.md at master · Homebrew/brewいうトラブルシューティング文書が気になりはじめました。
この文章に沿ってコマンドを実行し問題を解消してみようかと思います。


前提

以下の環境で実行しています。
* OS

% sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.12.6
BuildVersion:   16G29


brew/Troubleshooting.md について

よくある質問にあたるページです。
基本的にこのページの記載事項を実行後、それでも解決できなければ issue を検索し、それでも解決できない場合は、以下を実施するように記載されています。

  1. formula紐づく問題であれば、brew gist-logs <formula > コマンドで、問題を報告。

  2. formula紐づく問題でなければ、brew config と、brew doctorアウトプットを取得し、Gist を作成する。

とあります。1
[1]formula調理法というのが本来の意味だそうです。

homebrew が自体の何 であるのかは以下の記事が参考になりました。


Check for common issues手順を踏む

以下、Check for common issues手順を踏んで、brew の状態を確認します。

brew update2回実行

Run brew update twice.

何故2回なのか理由はよくわかりませんが、2回実行します。

1度目

% brew update
Updated 3 taps (caskroom/cask, homebrew/core, homebrew/science).
==> New Formulae
....
==> Updated Formulae
....
==> Renamed Formulae
....
==> Deleted Formulae
....
結構な時間がかかり、Formulae更新が行われました。

2度目

% brew update
Updated 1 tap (homebrew/core).
==> Updated Formulae
....
確かに2度更新されました。ふと3度目実行したらどうなるのか気になりましたので、3度目を実行します。

3度目

% brew update
Already up-to-date.
3度目は何も更新されませんでした。

brew doctor を実行し警告に対処する。

Run brew doctor and fix all the warnings

brew doctor を実行し、警告に対処します。

brew docorの実行

% brew doctor
Warning: Your XQuartz (2.7.8) is outdated.
...
Warning: Unbrewed header files were found in /usr/local/include.
...
Warning: You have unlinked kegs in your Cellar   
...
Warning: Some directories in your path end in a slash.
...
Warning: Broken symlinks were found. Remove them with `brew prune`:
...
Warning: Some installed formula are missing dependencies.
...
Warning: Some keg-only formula are linked into the Cellar.
...

警告への対処

出力された警告に対して対処をしていきます。

  • Warning: Your XQuartz (2.7.8) is outdated.
    MacにHomebrewをインストールする手順とWarningの解決方法 - Qiita記載があります。
    XQuartz の最新版をインストールすると解消されます。
    brew cask reinstall で xquartz を指定します。

    brew cask reinstall xquartz
    Warning: /usr/local is not writable, sudo is needed to move the Caskroom.
    
    Warning が出力されますが、気にせず sudo して進めます。
    🍺  xquartz was successfully installed!
    
    インストールに成功しました。

  • Warning: Unbrewed header files were found in /usr/local/include.
    [macOS] OS X Yosemite へ update 後の brew doctor でエラーが出たので直す | deadwood記載があります。
    対象の include ファイルを削除します。

    rm -f /usr/local/include/python3.4m/greenlet/greenlet.h
    

  • Warning: You have unlinked kegs in your Cellar
    コマンドラインでbrew doctorすると警告だらけになっちゃった助けて - Qiita記載があります。
    メッセージの通りですが、brew link <formula > すると解消します。
    私の環境の場合は、出力されているものは無視しても構わない勝手知ったるものだったので、無視しました。

  • Warning: Some directories in your path end in a slash.
    パスが/終わるのはあまりよくないらしく、path 通していた対象記述の末尾の/除去しました。

  • Warning: Broken symlinks were found. Remove them with brew prune:
    Homebrewのアップデート時に出た5つのWarningと解決方法 - Qiita記載があります。
    brew prune実行します。

    brew prune
    Error: Permission denied -...
    
    記事と同様にパーミッションがなくエラーとなったため、ログインユーザーに権限を付与し、再度コマンドを実行、解消しました。

  • Warning: Some installed formula are missing dependencies.
    homebrew brew doctorトラブルシューティング - bismar’s blog記載があります。
    警告表示されているコマンドを実行します。

    brew install fontconfig gd gmp@4 isl@0.12 jpeg libtiff libtool webp
    

  • Warning: Some keg-only formula are linked into the Cellar.
    Warning: You have unlinked kegs in your Cellar対応するライブラリで警告が出ていましたので、無視しました。

CLT と Xcode が最新版であることを確認する

brew doctor最新版でない場合は警告が出るようです。
警告が出ていないため最新版であると判断しました。

パーミッションエラーが出た場合は適切な権限に修正する

こちらは、コマンド実施中に変更していますので、問題なしと判断しました。

brew/Common-Issues.md at master · Homebrew/brew確認する

https://github.com/Homebrew/brew/blob/master/docs/Common-Issues.md確認すると、MAC OS に対する記載がありました。
MAC OS を Upgrade した際は、CLTの再インストールと、brew upgrade を実施が必要かもしれない とのことなので、
試しにコマンドを実行してみます。

% xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
インストール済らしく、エラーメッセージが表示されました。
意味はあまりないかもしれませんが、brew upgrade だけを実施します。

% brew upgrade
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/science).
==> Updated Formulae
homebrew/science/prodigal                                                              homebrew/science/sga

==> Upgrading 26 outdated packages, with result:
clasp 3.3.2, cloog 0.18.4_1, doxygen 1.8.13_1, elasticsearch 5.5.2, gauge 0.9.1, git 2.14.1, gradle 4.1, graphviz 2.40.1, infer 0.12.0_1, libyaml 0.1.7, logstash 5.5.2, maven 3.5.0, mongodb 3.4.7, nmap 7.60, node 8.4.0, pandoc 1.19.2.1, pkg-config 0.29.2, postgresql 9.6.4, postgresql@9.5 9.5.8, pyenv 1.1.3, python3 3.6.2, redpen 1.9.0, sonar-scanner 3.0.3.778, sqlite 3.20.1, xz 5.2.3, zeromq 4.2.2
何も起きないと思ったのですが、ゴリゴリインストールされ始めました...... 2
[2]postgresql あたりで問題が起きると非常に悲しいです…

brew update2回実行を再度実行

upgrade後のため、再度 brew update を実施します。

1度目

% brew update
brew update
Updated 2 taps (homebrew/core, homebrew/science).
==> Updated Formulae
......
update がかかりました。

2度目

% brew update
brew update
Already up-to-date.
2度目はOKです。

brew docorの実行

% brew doctor
Warning: You have unlinked kegs in your Cellar
....
Warning: Some keg-only formula are linked into the Cellar.
見送った Warning のみ出力されました。
brew doctor は問題ありません。


まとめ

以下まとめます。

  • brew update2回実行 したほうがよい
    完全に最新化されるのに2回かかるという挙動になりました。2回実行するべきです。

  • brew doctor警告は勝手知ったるものならば、見送る インストールの都合上警告が上がるケースは見送っても問題はないと思います。

  • brew upgradeするなら、最初に実行しておいたほうがいい
    2度手間になるので、brew upgradeするなら、brew update前に実行したほうがいいかと思います。

  • 面倒くさい
    時間もかかる上に、面倒くさいです。brew doctor削除コマンドとか自動生成してくれるツールがあるとうれしいかもしれません。

面倒くさかったですが、以上です。

コメント