How to Fix Permissions on Home-brew on MacOS High Sierra

Viewed 40500

When I tried to install python onto homebrew it downloaded it and then an error message popped up at the end that stopped it from completing. When I try to do it again it asks me to do:

$ brew link python

After entering that the same error message appears:

permission denied @ dir_s_mkdir - /usr/local/lib

I have tried to do:

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

And I get an error message that reads:

chown: /usr/local: Operation not permitted

14 Answers
sudo mkdir /usr/local/Frameworks

sudo chown $USER /usr/local/Frameworks

And then try re-installing python. This worked absolutely fine for me.

Run this, and follow its suggestions:

brew doctor

In my case, it wanted me to run:

sudo mkdir -p /usr/local/sbin /usr/local/Frameworks
sudo chown -R $(whoami) /usr/local/sbin /usr/local/Frameworks

In my case with MacOS 10.14 fresh installation in a new machine:

brew doctor

And it suggests:

sudo mkdir -p /usr/local/lib /usr/local/sbin
sudo chown -R $(whoami) /usr/local/lib /usr/local/sbin

Command for users on macOS

bash/zsh:

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

fish:

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

I reinstalled brew and fixed the issue.

to uninstall use the following command.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

and to install brew again.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor

This command, as suggested by Chris above in the comments, solved almost ALL my home-brew issues running on a Mac Mini 2011 5,1 unofficially running MacOS Mojave. Simply enter that and follow all directions that terminal prints

I just did this and it worked ok:

sudo touch /usr/local/Frameworks
brew link python

Using this command

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