[Mac] Fixing 'Error: /usr/local must be writable!' with brew update

Tadashi Shigeoka ·  Sat, January 21, 2017

This is how to fix the issue when you get Error: /usr/local must be writable! with brew update.

$ brew update
Error: /usr/local must be writable!

When I looked it up, it suggested trying brew doctor first, so let me try that.

$ 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

Warning: /usr/local is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. For example, upgrading
to OS X El Capitan has been known to do this. Some versions of the
"InstantOn" component of Airfoil or running Cocktail cleanup/optimizations
are known to do this as well.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami) /usr/local

Warning: Some installed formula are missing dependencies.
You should `brew install` the missing dependencies:
  brew install oniguruma

Run `brew missing` for more details.

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.

It says to run sudo chown -R $(whoami) /usr/local, so I’ll execute that and try brew update again.

sudo chown -R $(whoami) /usr/local

Next, I got an error saying update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory.

brew update

/usr/local/Library/Homebrew/cmd/update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory
(omitted)
/usr/local/Library/Homebrew/cmd/update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory
Error: update-report should not be called directly!
brew prune

Sometimes brew update can be troublesome…

Reference Information

That’s all from the Gemba.