はじめに
私用Macで作業中に、ふと「そういえば最近brew doctorしてないな...」という嫌な予感がしたため実行してみたら例によって大量に警告が出たため対処した際の備忘録。
やったこと
macOS Big Sur環境で下記を実施した。
-
brew updateでHomebrewの更新 -
brew doctorで問題診断
Homebrew 3.3.7
Homebrew/homebrew-core (git revision cc09a2dd136; last commit 2021-12-08)
Homebrew/homebrew-cask (git revision ae48a06637; last commit 2021-12-08)
CommandLineToolsの更新を促す警告
Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
softwareupdate --all --install --force
If that doesn't show you any updates, run:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Alternatively, manually download them from:
https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.1.
これはよくある警告なので、(可能であれば)更新すれば良い。
ただし、初回下記を実行するも特に更新がなかった。
softwareupdate --all --install --force
そのため、下記コマンドで一旦CommandLineTools削除してから再インストール。
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
改めて、下記コマンドできちんと更新され解決。
softwareupdate --all --install --force
ファイルが大量にModified扱いとなる
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 /usr/local/Homebrew && git stash && git clean -d -f
Uncommitted files:
M .dockerignore
M .editorconfig
M .github/ISSUE_TEMPLATE.md
M .github/ISSUE_TEMPLATE/bug.yml
M .github/ISSUE_TEMPLATE/config.yml
M .github/ISSUE_TEMPLATE/feature.yml
M .github/PULL_REQUEST_TEMPLATE.md
M .github/codecov.yml
M .github/dependabot.yml
M .github/release.yml
M .github/workflows/docker.yml
M .github/workflows/doctor.yml
(以下多すぎるため割愛)
大量にファイルが列挙され他の警告が埋もれるため一番消したかった警告。
初めて遭遇したパターン。発生原因までは調査できていないが、対症療法としてはbrew doctorの指示通り下記を実行。
cd /usr/local/Homebrew && git stash && git clean -d -f
上記実行後、解決したかを確認するため再度brew doctorしたところ、依然と大量のファイルがModifiedとなっていた。「あれ...解決していないのか?」と思いきや、よく見ると異なるパス(homebrew-coreとhomebrew-cask)で警告されているだけだったため、再度パス違いのコマンドを実行する必要があった。
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash && git clean -d -f
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask && git stash && git clean -d -f
*-configがパスに複数見つかる旨の警告
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 which 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/xxx/.anyenv/envs/pyenv/shims/python3.10-config
/Users/xxx/.anyenv/envs/pyenv/shims/python3.9-config
/Users/xxx/.anyenv/envs/pyenv/shims/python-config
/Users/xxx/.anyenv/envs/pyenv/shims/python3-config
/Users/xxx/.anyenv/envs/pyenv/shims/ansible-config
/Applications/Postgres.app/Contents/Versions/latest/bin/gdal-config
結論的には下記でbrewのエイリアスを作成することで回避。
alias brew="PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin brew"
以下、補足や蛇足。
先ず私の環境ではanyenv経由でpyenvを利用しており、下記にあるようにpyenv関連のconfigファイルが混在してしまっている様子。
/Users/xxx/.anyenv/envs/pyenv/shims/python3.10-config
/Users/xxx/.anyenv/envs/pyenv/shims/python3.9-config
/Users/xxx/.anyenv/envs/pyenv/shims/python-config
/Users/xxx/.anyenv/envs/pyenv/shims/python3-config
/Users/xxx/.anyenv/envs/pyenv/shims/ansible-config
pyenvのREADMEを見た所、下記のような記載があることに気づいた。
3. OPTIONAL. To fix brew doctor's warning ""config" scripts exist outside your system or Homebrew directories"
そこで掲載されている下記のエイリアスをzshrc等に追記。
alias brew='env PATH="${PATH//$(pyenv root)\/shims:/}" brew'
これで確かにpyenv関連の警告は消えた。
ただし、下記のようにPostgres.appに関する警告も出ていたため別途対応する必要がある。
/Applications/Postgres.app/Contents/Versions/latest/bin/gdal-config
Postgres.appのリポジトリを見たところ、2016年頃からIssueがOpenしている。
5年以上前からOpenのままであり、単なる警告だからかPostgres.app側はあまり対処する気はなさそう。pyenvのREADMEで記載されているパスではなく下記のようにすることで回避できたため、これを採用することにした。
alias brew="PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin brew"
pythonのsixに関する警告
Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
six
brewでMySQLをインストールしたことで生じた警告の様子。MySQLの依存関係にsixがある。
$ brew deps mysql
ca-certificates
icu4c
libevent
lz4
openssl@1.1
protobuf
six
zstd
なお、protobufがsix依存の様子。
$ brew deps protobuf
six
普段pyenvとの兼ね合いから、brewでpythonをインストールすることを控えきたが、致し方なくbrew install pythonでpython3系(python 3.9)をインストールすることで回避することにした。
終わりに
無事下記のメッセージを見て安心しつつ「あれ?そういえば何してたんだっけ...」となりました。こまめに診断しておきたいところですね、反省。
$ brew doctor
Your system is ready to brew.