14
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【随時更新】brew doctorでWarning: xxxxxxx.と表示された時の処方箋

Last updated at Posted at 2021-01-07

MacのパッケージマネージャーHomebrewには現在の状態を表示するdoctorコマンドが有ります。通常は以下の様にYour system is ready to brew.と出力されるのが理想です。

$ brew doctor 
Your system is ready to brew.

ところが、使っていると様々な要因で健康診断に引っ掛かる様になります。

症例1: Warning: You have unlinked kegs in your Cellar.

Homebrewが管理しているアプリケーションのシンボリックリンクが壊れた場合にこの症状が出ます。

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:
  r
  gcc@8

Warning: Broken symlinks were found. Remove them with `brew cleanup`:
  /usr/local/bin/c++-8
  /usr/local/bin/cpp-8
  /usr/local/bin/g++
  /usr/local/bin/g++-8
  /usr/local/bin/gcc
  /usr/local/bin/gcc-8
  /usr/local/bin/gcc-ar-8
  /usr/local/bin/gcc-nm-8
  /usr/local/bin/gcc-ranlib-8
  /usr/local/bin/gcov-8
  /usr/local/bin/gcov-dump-8
  /usr/local/bin/gcov-tool-8
  /usr/local/bin/gfortran-8
  /usr/local/bin/x86_64-apple-darwin20-c++-8
  /usr/local/bin/x86_64-apple-darwin20-g++-8
  /usr/local/bin/x86_64-apple-darwin20-gcc-8
  /usr/local/bin/x86_64-apple-darwin20-gcc-8.4.0
  /usr/local/bin/x86_64-apple-darwin20-gcc-ar-8
  /usr/local/bin/x86_64-apple-darwin20-gcc-nm-8
  /usr/local/bin/x86_64-apple-darwin20-gcc-ranlib-8
  /usr/local/bin/x86_64-apple-darwin20-gfortran-8
  /usr/local/include/c++/8.4.0
  /usr/local/lib/gcc/8
  /usr/local/share/gcc-8.4.0
  /usr/local/share/man/man1/cpp-8.1
  /usr/local/share/man/man1/g++-8.1
  /usr/local/share/man/man1/gcc-8.1
  /usr/local/share/man/man1/gcov-8.1
  /usr/local/share/man/man1/gcov-dump-8.1
  /usr/local/share/man/man1/gcov-tool-8.1
  /usr/local/share/man/man1/gfortran-8.1
  /usr/local/share/man/man7/fsf-funding-8.7
  /usr/local/share/man/man7/gfdl-8.7
  /usr/local/share/man/man7/gpl-8.7

処方箋

brew linkコマンドで修復します。

brew link r gcc@8

症例2: Warning: Some installed formulae are deprecated or disabled.

この症例は1つのアプリケーションに対して複数のバージョンがインストールされている状態で出る場合が有る様です。筆者の環境ではlua@5.1とlua@5.4がインストールされており、競合状態となっていたため、警告が出ました。

$ 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 or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  lua@5.1

処方箋

警告で表示されているバージョンをアンインストールすると直りました。

brew uninstall lua@5.1

症例3: Warning: Broken symlinks were found.

何らかの原因でシンボリックリンクが壊れた状態になっている場合に発生する様です。

$ 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 or file an issue; just ignore this. Thanks!

Warning: Broken symlinks were found. Remove them with `brew cleanup`:
  /opt/homebrew/etc/bash_completion.d/docker-compose

確かにリンク切れになっています。

$ ls /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion
ls: /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion: No such file or directory

処方箋

メッセージで表示されている様にbrew cleanupを実行します。

brew cleanup

症例4: Warning: You have uncommitted modifications to Homebrew/brew.

何らかの変更がHomebrew管理下のアプリケーションに加わった時に発生するようです。

$ 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 or file an issue; just ignore this. Thanks!

Warning: You have uncommitted modifications to Homebrew/brew.
If this is a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
  cd /opt/homebrew && git stash -u && git clean -d -f

Uncommitted files:
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.7.2/MIT-LICENSE
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/addressable-2.8.1/LICENSE.txt
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/connection_pool-2.3.0/LICENSE
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/domain_name-0.5.20190701/LICENSE.txt
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/http-cookie-1.0.5/LICENSE.txt
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.12.0/MIT-LICENSE
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/mechanize-2.8.5/LICENSE.txt
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.13.10-arm64-darwin/LICENSE-DEPENDENCIES.md
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.13.10-arm64-darwin/LICENSE.md
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/public_suffix-5.0.1/LICENSE.txt
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/LICENSE
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubyntlm-0.6.3/LICENSE
  ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/webrick-1.8.1/LICENSE.txt

処方箋

メッセージに表示されている様にcd /opt/homebrew && git stash -u && git clean -d -fを実行します。

$ cd /opt/homebrew && git stash -u && git clean -d -f
Saved working directory and index state WIP on stable: e57a87cfe Merge pull request #16085 from samford/improve-date-version-parsing-take-2

処方箋実行後、brew doctorを再度実行します。

$ brew doctor 
Your system is ready to brew.

症例5: Warning: Some installed kegs have no formulae!

どこかのタイミングでHomebrewのインストール済アプリのデータベースの整合性が崩れてしまったことが原因の様です。

$ 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 or file an issue; just ignore this. Thanks!

Warning: Some installed kegs have no formulae!
This means they were either deleted or installed manually.
You should find replacements for the following formulae:
  python-platformdirs
  python-distlib
  python-filelock

処方箋

brew uninsall --ignore-dependencies xxxxxを実行します。

$ brew uninstall --ignore-dependencies python-platformdirs python-distlib python-filelock
Uninstalling /opt/homebrew/Cellar/python-platformdirs/4.2.0... (36 files, 172.2KB)
Uninstalling /opt/homebrew/Cellar/python-distlib/0.3.8... (59 files, 2.3MB)
Uninstalling /opt/homebrew/Cellar/python-filelock/3.13.1... (36 files, 60.3KB)

因みに、--ignore-dependenciesオプションを着けない場合は、以下の様にエラーとなります。

$ brew uninstall python-platformdirs python-distlib python-filelock
Error: Refusing to uninstall /opt/homebrew/Cellar/python-distlib/0.3.8, /opt/homebrew/Cellar/python-filelock/3.13.1 and /opt/homebrew/Cellar/python-platformdirs/4.2.0
because they are required by pipenv and virtualenv, which are currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies python-platformdirs python-distlib python-filelock

Warning: /usr/bin occurs before /opt/homebrew/bin in your PATH.

$ 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 or file an issue; just ignore this. Thanks!

Warning: /usr/bin occurs before /opt/homebrew/bin in your PATH.
This means that system-provided programs will be used instead of those
provided by Homebrew. Consider setting your PATH so that
/opt/homebrew/bin occurs before /usr/bin. Here is a one-liner:
  echo 'export PATH="/opt/homebrew/bin:$PATH"' >> /Users/yuhkiyano/.bash_profile

The following tools exist at both paths:
  bashbug
  corelist
  cpan
  enc2xs
  encguess
  ex
  git
  git-receive-pack
  git-shell
  git-upload-archive
  git-upload-pack
  h2ph
  h2xs
  instmodsh
  json_pp
  libnetcfg
  openssl
  perl
  perlbug
  perldoc
  perlivp
  perlthanks
  piconv
  pip3
  pl2pm
  pod2html
  pod2man
  pod2text
  pod2usage
  podchecker
  prove
  ptar
  ptardiff
  ptargrep
  python3
  rview
  rvim
  shasum
  splain
  streamzip
  tclsh
  vi
  view
  vim
  vimdiff
  vimtutor
  wish
  xsubpp
  xxd
  zipdetails

処方箋

この警告が出る時は、環境変数PATH内で/usr/binよりも先に/opt/homebrew/binが宣言されてしまっているので、PATHの宣言の順番等を確認して正しい順番になっているかまずは確認します。警告メッセージに対処方法が記載されていますが、あくまで対処療法でしかなく、根本解決にはなりません。

Reference

14
9
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
14
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?