1. 起こったこと

Mac OS を El Capitan に Upgrade 後、java をインストールするため、

brew install autoconf automake opam caskroom/cask/brew-cask && \
brew cask install caskroom/versions/java7

を実行したところ、以下のエラーが出力されました。

Error: undefined method `<' for nil:NilClass
Please report this bug:
    https://git.io/brew-troubleshooting
/usr/local/Library/Homebrew/formula_support.rb:21:in `valid?'

エラー原因と解決方法を調べましたので、メモします。
完全な解決には至りませんでしたが、インストールというゴールには辿りつけました。


2. エラー原因と解決方法

原因は多分、以下の issue の内容と同じです。

どちらの issue にも OS El Capitan に Upgrade したことによる問題である旨が記載されています。
Issue #45233 に、brew/Troubleshooting.md at master · Homebrew/brew見て対処しなさいとの記載があります。
Check for common issues記載の内容を試しながら進めます。

  • brew updateを 実行する。
    Check for common issues には2度実行しなさいと書いてあります。
    1回目を実施します。

    brew update
    

  • 結果

    Error: /usr/local must be writable!
    

  • 追記 2017/08/30
    どうも、OS Upgrade により /usr/local のディレクトリ権限が変わっていたようです。
    以下記事に記載がありますが、権限変更での対処も可能です。
    私は、この時そのまま先に進めました。
    brew updateをしたらError: /usr/local must be writable!が出た - Qiita
    Homebrew の update が失敗する問題

  • sudo brew update を 実行。 通常の brew で実行ができなかったので、sudo を付与して実行します。

    sudo brew update
    

  • 結果

    Password:
    Error: Cowardly refusing to 'sudo brew update'
    You can use brew with sudo, but only if the brew executable is owned by root.
    However, this is both not recommended and completely unsupported so do so at
    your own risk.
    
    brew は brewの実行コマンド類の持ち主がroot の場合のみ、sudo で実行できると言っています。
    自己責任で変えてとあるので、変えることは見送り、Check for common issues従い先に進めます。

  • brew doctor を実行
    brew doctor を実行して全ての警告を解消しなさいとあるので、実行します。

    brew doctor
    

  • 結果

    Please note that these warnings are just used to help the Homebrew maintainers
    with debugging if you file an issue. If everything you use Homebrew for is
    working fine: please don't worry and just ignore them. Thanks!
    
    Warning: The /usr/local is not writable.
    
    You should probably change the ownership and permissions of /usr/local
    back to your user account.
      sudo chown -R $(whoami) /usr/local
    
    Warning: The /usr/local directory is not writable.
    Even if this directory was writable when you installed Homebrew, other
    software may change permissions on this directory. For example, upgrading
    to OS X El Capitan has been known to do this. Some versions of the
    "InstantOn" component of Airfoil or running Cocktail cleanup/optimizations
    are known to do this as well.
    
    You should probably change the ownership and permissions of /usr/local
    back to your user account.
      sudo chown -R $(whoami):admin /usr/local
    Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool
    
    /usr/local 以下の権限設定がおかしいよという警告が出力されています。

  • 警告の通りに、権限を変更する
    MAC の ログインユーザーに/usr/local ディレクトリの権限を付与します。

    sudo chown -R $(whoami) /usr/local
    sudo chown -R $(whoami):admin /usr/local
    

  • 再度、brew doctorを実行

    brew doctor
    

  • 結果

    Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool
    
    エラーが消えません。
    上記エラーで検索すると、Mac OS X YosemiteにHomebrewをインストール - @uents blogヒットします。
    xcodeをインストールすると解決したとあるので、xcodeをインストールします。
    xcode-select --install
    

  • インストール完了 brew doctorを再度実施

    brew doctor
    

  • 結果

    Please note that these warnings are just used to help the Homebrew maintainers
    with debugging if you file an issue. If everything you use Homebrew for is
    working fine: please don't worry and just ignore them. Thanks!
    
    Warning: Unbrewed header files were found in /usr/local/include.
    If you didn't put them there on purpose they could cause problems when
    building Homebrew formulae, and may need to be deleted.
    
    Unexpected header files:
        /usr/local/include/python3.4m/greenlet/greenlet.h
    
    Warning: You have unlinked kegs in your Cellar
    Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
    those kegs to fail to run properly once built. Run `brew link` on these:
        autoconf
    
    Warning: Broken symlinks were found. Remove them with `brew prune`:
        /usr/local/bin/apm
        /usr/local/bin/atom
    
    Warning: Your Homebrew is outdated.
    You haven't updated for at least 24 hours. This is a long time in brewland!
    To update Homebrew, run `brew update`.
    
    警告解消のために、brew linkbrew prunebrew update実行しなさいと出力されました。

  • brew prune,brew update,brew linkを実行

    brew prune
    brew update
    brew link
    

  • 結果

    $ brew prune
    Pruned 2 symbolic links from /usr/local
    $ brew update
    ==> Migrating Homebrew to v0.9.9
    remote: Counting objects: 462, done.
    remote: Compressing objects: 100% (420/420), done.
    remote: Total 462 (delta 28), reused 284 (delta 17), pack-reused 0
    Receiving objects: 100% (462/462), 751.72 KiB | 387.00 KiB/s, done.
    Resolving deltas: 100% (28/28), done.
    From https://github.com/Homebrew/brew
     + 53c5089...0fe6ace master     -> origin/master  (forced update)
    HEAD is now at 0fe6ace tests: ensure desc prints short name only if there are conflicts
    ==> Tapping homebrew/core
    Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'...
    remote: Counting objects: 3664, done.
    remote: Compressing objects: 100% (3549/3549), done.
    remote: Total 3664 (delta 16), reused 451 (delta 3), pack-reused 0
    Receiving objects: 100% (3664/3664), 2.79 MiB | 506.00 KiB/s, done.
    Resolving deltas: 100% (16/16), done.
    Checking connectivity... done.
    Tapped 3539 formulae (3,690 files, 8.7M)
    Already up-to-date.
    $ brew link
    This command requires a keg argument
    

  • brew link は失敗したようですが、問題なさそうなので、brew doctorを実行

    brew doctor
    

  • 結果

    Please note that these warnings are just used to help the Homebrew maintainers
    with debugging if you file an issue. If everything you use Homebrew for is
    working fine: please don't worry and just ignore them. Thanks!
    
    Warning: Unbrewed header files were found in /usr/local/include.
    If you didn't put them there on purpose they could cause problems when
    building Homebrew formulae, and may need to be deleted.
    
    Unexpected header files:
        /usr/local/include/python3.4m/greenlet/greenlet.h
    
    Warning: You have unlinked kegs in your Cellar
    Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
    those kegs to fail to run properly once built. Run `brew link` on these:
        autoconf
    

  • 追記 2017/08/30
    下で実行していますが、 brew link autoconf 実行でWaring は解消されるかと思います。
    私は当時すっ飛ばして行きましたが、それでも問題なくインストールできました。

  • あまり変わってなさそうだが、試しに問題となったコマンドを実施

    brew install autoconf automake opam caskroom/cask/brew-cask && \
    brew cask install caskroom/versions/java7
    

  • 結果

    ==> brew cask install caskroom/cask/brew-cask
    ==> We need to make Caskroom for the first time at /opt/homebrew-cask/Caskroom
    ==> We'll set permissions properly so we won't need sudo in the future
    Password:
    Error: No available Cask for caskroom/cask/brew-cask
    Error: nothing to install
    Warning: autoconf-2.69 already installed, it's just not linked
    Error: You must `brew link autoconf` before automake can be installed
    ==> Installing dependencies for opam: ocaml, camlp4, gringo, clasp, aspcud
    ==> Installing opam dependency: ocaml
    ==> Downloading https://homebrew.bintray.com/bottles/ocaml-4.02.3.el_capitan.bottle.tar.gz
    ######################################################################## 100.0%
    ==> Pouring ocaml-4.02.3.el_capitan.bottle.tar.gz
    🍺  /usr/local/Cellar/ocaml/4.02.3: 1,187 files, 112.3M
    ==> Installing opam dependency: camlp4
    ==> Downloading https://homebrew.bintray.com/bottles/camlp4-4.02.3+6.el_capitan.bottle.tar.gz
    ######################################################################## 100.0%
    ==> Pouring camlp4-4.02.3+6.el_capitan.bottle.tar.gz
    🍺  /usr/local/Cellar/camlp4/4.02.3+6: 164 files, 132.5M
    ==> Installing opam dependency: gringo
    ==> Downloading https://homebrew.bintray.com/bottles/gringo-4.5.3.el_capitan.bottle.tar.gz
    ######################################################################## 100.0%
    ==> Pouring gringo-4.5.3.el_capitan.bottle.tar.gz
    🍺  /usr/local/Cellar/gringo/4.5.3: 7 files, 5.7M
    ==> Installing opam dependency: clasp
    ==> Downloading https://homebrew.bintray.com/bottles/clasp-3.1.3.el_capitan.bottle.tar.gz
    ######################################################################## 100.0%
    ==> Pouring clasp-3.1.3.el_capitan.bottle.tar.gz
    🍺  /usr/local/Cellar/clasp/3.1.3: 5 files, 1011.4K
    ==> Installing opam dependency: aspcud
    ==> Downloading https://homebrew.bintray.com/bottles/aspcud-1.9.1.el_capitan.bottle.1.tar.gz
    ######################################################################## 100.0%
    ==> Pouring aspcud-1.9.1.el_capitan.bottle.1.tar.gz
    🍺  /usr/local/Cellar/aspcud/1.9.1: 10 files, 510.7K
    ==> Installing opam
    ==> Downloading https://homebrew.bintray.com/bottles/opam-1.2.2_1.el_capitan.bottle.1.tar.gz
    ######################################################################## 100.0%
    ==> Pouring opam-1.2.2_1.el_capitan.bottle.1.tar.gz
    ==> Caveats
    OPAM uses ~/.opam by default for its package database, so you need to
    initialize it first by running (as a normal user):
    
    $  opam init
    
    Run the following to initialize your environment variables:
    
    $  eval `opam config env`
    
    To export the needed variables every time, add them to your dotfiles.
      * On Bash, add them to `~/.bash_profile`.
      * On Zsh, add them to `~/.zprofile` or `~/.zshrc` instead.
    
    Documentation and tutorials are available at https://opam.ocaml.org, or
    via "man opam" and "opam --help".
    
    Bash completion has been installed to:
      /usr/local/etc/bash_completion.d
    
    zsh completion has been installed to:
      /usr/local/share/zsh/site-functions
    ==> Summary
    🍺  /usr/local/Cellar/opam/1.2.2_1: 30 files, 19.0M
    

  • 先には進んだように思う。brew link autoconf実行しろとのこと?なので実行

    brew link autoconf
    

  • 結果

    Please note that these warnings are just used to help the Homebrew maintainers
    with debugging if you file an issue. If everything you use Homebrew for is
    working fine: please don't worry and just ignore them. Thanks!
    
    Warning: Unbrewed header files were found in /usr/local/include.
    If you didn't put them there on purpose they could cause problems when
    building Homebrew formulae, and may need to be deleted.
    
    Unexpected header files:
        /usr/local/include/python3.4m/greenlet/greenlet.h
    

  • 追記 2017/08/30
    正直、今もあまり原因がわかっていないですが、brew warning caused by greenlet · Issue #38152 · Homebrew/legacy-homebrew上記に関連する issue が存在します。
    homebrew - Brew doctor - “warning: unbrewed header files were found in /usr/local/include”? - Stack Overflow確認する限りは、ゴミヘッダファイルは削除したほうがいいのかもしれません。


WARING は出力されているが、install 自体は出来ていそうです。
あんまり腑に落ちない形ですが「以上」、です。

コメント