LoginSignup
2
2

More than 5 years have passed since last update.

brew warningを消す

Last updated at Posted at 2017-01-30

Scriptsのワーニング

Pythonを入れていると、

brew doctor

を実行した時に、次のようなワーニングが出てしまう。

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /Users/knaito/.pyenv/shims/libdynd-config
  /Users/knaito/.pyenv/shims/libpng16-config
  /Users/knaito/.pyenv/shims/python-config
  /Users/knaito/.pyenv/shims/python2-config
  /Users/knaito/.pyenv/shims/python2.7-config

brewで管理していないconfigファイルがあるからワーニングが出てしまっている。

ワーニングが出ていても動作に問題はないのだが、煩わしいので消したい。
解決方法の一つとして、brewを実行した場合だけpathから.pyenv/shimsディレクトリを除外するというものがある。http://www.task-notes.com/entry/20141223/1419324649

しかしここでは、alias以外の方法を探してみる。
/usr/local/Homebrew/Library/Homebrew/diagnostic.rb
を見ると、check_for_config_scriptsメソッド内の604行目くらいから
ホワイトリスト

       whitelist = %W[
          /usr/bin /usr/sbin
          /usr/X11/bin /usr/X11R6/bin /opt/X11/bin
          #{HOMEBREW_PREFIX}/bin #{HOMEBREW_PREFIX}/sbin
          /Applications/Server.app/Contents/ServerRoot/usr/bin
          /Applications/Server.app/Contents/ServerRoot/usr/sbin
        ].map(&:downcase)

が設定されているので、ここに、.pyenv/shimsを追加してみる。

        whitelist = %W[
          /usr/bin /usr/sbin
          /usr/X11/bin /usr/X11R6/bin /opt/X11/bin
          #{HOMEBREW_PREFIX}/bin #{HOMEBREW_PREFIX}/sbin
          /Applications/Server.app/Contents/ServerRoot/usr/bin
          /Applications/Server.app/Contents/ServerRoot/usr/sbin
          /Users/knaito/.pyenv/shims
        ].map(&:downcase)

(knaitoの部分は、自分のユーザー名にすること)

これで、上記のワーニングは出なくなる。

ただし、今度はgitのワーニングが出てしまうので、/usr/local/Homebrewに
移動して

$ get checkout -b custom
$ git add -A
$ git commit -m "Python code are ignored in doctor"

のようにコミットしておく。
アップデートするときは、masterブランチに変更して、アップデートして、customブランチにマージするなどが必要かもしれない、、。

ライブラリのワーニング

brewで管理していない
/usr/local/lib/libcaffe.a
などがあると、これもbrew doctorでワーニングが出てしまう。

Unexpected static libraries:
  /usr/local/lib/libcaffe.a

これもまた、
/usr/local/Homebrew/Library/Homebrew/diagnostic.rb
のcheck_for_stray_static_libsメソッド内の185行目あたりの
ホワイトリスト定義

        white_list = [
          "libsecurity_agent_client.a", # OS X 10.8.2 Supplemental Update
          "libsecurity_agent_server.a", # OS X 10.8.2 Supplemental Update
          "libntfs-3g.a", # NTFS-3G
          "libntfs.a", # NTFS-3G
          "libublio.a", # NTFS-3G
          "libappfirewall.a", # Symantec Endpoint Protection
          "libautoblock.a", # Symantec Endpoint Protection
          "libautosetup.a", # Symantec Endpoint Protection
          "libconnectionsclient.a", # Symantec Endpoint Protection
          "liblocationawareness.a", # Symantec Endpoint Protection
          "libpersonalfirewall.a", # Symantec Endpoint Protection
          "libtrustedcomponents.a", # Symantec Endpoint Protection
        ]

に、libcaffe.aを追加して

        white_list = [
          "libsecurity_agent_client.a", # OS X 10.8.2 Supplemental Update
          "libsecurity_agent_server.a", # OS X 10.8.2 Supplemental Update
          "libntfs-3g.a", # NTFS-3G
          "libntfs.a", # NTFS-3G
          "libublio.a", # NTFS-3G
          "libappfirewall.a", # Symantec Endpoint Protection
          "libautoblock.a", # Symantec Endpoint Protection
          "libautosetup.a", # Symantec Endpoint Protection
          "libconnectionsclient.a", # Symantec Endpoint Protection
          "liblocationawareness.a", # Symantec Endpoint Protection
          "libpersonalfirewall.a", # Symantec Endpoint Protection
          "libtrustedcomponents.a", # Symantec Endpoint Protection
          "libcaffe.a", # Caffe manual installed
        ]

のようにすれば、ワーニングされないようになる。

再度、gitで/usr/local/Homebrewをコミットしておく。

$ get checkout -b naito_custom
$ git add -A
$ git commit -m "Caffe and python code are ignored in doctor"

これでOK。

その他

できれば、brewに機能追加して、ユーザー側でカスタムwhitelistを簡単に設定出来るといいのだけど、、、。誰かpull requestしていただけないかな?

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2