brew update fails with "Permission denied" error

In Mac OSX Mojave, installing Python3, I solved this issue by the following:

sudo mkdir /usr/local/Frameworks
sudo chown -R user:group /usr/local/Frameworks/
brew link python

Where user and group are specified as set by the OS. You can find out what user/group values should be by doing:

 ls -al /usr/local

And then python3 was successfully installed:

> python3
Python 3.7.2 (default, Feb 12 2019, 08:15:36) 
[.Clang 10.0.0 (clang-1000.11.45.5)] on darwin

Try to change owner of /usr/local.

if you use macOS High Sierra or higher try this command:

sudo chown -R $(whoami) $(brew --prefix)/*

if you use macOS Sierra or lower:

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

Tags:

Macos

Homebrew