Original Answer
The problem mainly occurs after updating OS X to El Capitan (OS X 10.11) or macOS Sierra (macOS 10.12).
This is because of file permission issues with El Capitan’s or later macOS's new SIP process. Try changing the permissions for the /usr/local
directory:
$ sudo chown -R $(whoami):admin /usr/local
If it still doesn't work, use these steps inside a terminal session and everything will be fine:
cd /usr/local/Library/Homebrew
git reset --hard
git clean -df
brew update
If /usr/local/Library/Homebrew
doesn't work, try /usr/local/Homebrew
. The problem might be that Homebrew is outdated.
Apr 2021 Update
The command above doesn't work for macOS High Sierra or above, as explained in this GitHub issue. You have to run this instead:
sudo chown -R $(whoami) $(brew --prefix)/*
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…