Posted at

macOS Sierraへのアップグレード以前からインストールされていたbrewを更新する

More than 1 year has passed since last update.


macOS Sierra以前のEl Capitanなどでbrewをインストールし、クリーンインストールではなく上書きインストールした場合、brew updateを実行しようとするエラーが発生してしまう。

$ brew --version

Homebrew 1.1.9-131-gcf18a99
Homebrew/homebrew-core (git revision bdf98; last commit 2016-04-30)
$ brew update
Error: /usr/local must be writable!


brew doctorの指示に従って/usr/localのオーナーをsudo chown -R $(whoami) /usr/localで一時的に変更してbrew updateを実行し、実行後にsudo chown root:wheel /usr/localでオーナーを元に戻す。

$ 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: /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
$ brew update
Updating Homebrew...
==> Auto-updated Homebrew!
==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!
Homebrew no longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
sudo chown root:wheel /usr/local
$ sudo chown root:wheel /usr/local