Dan
Dan

Reputation: 2981

can't chown /usr/local for homebrew in Mac OS X 10.13 High Sierra

Homebrew needs permissions in /usr/local and since no one else uses my laptop I have always simply done

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

but in High Sierra, this gives

chown: /usr/local: Operation not permitted

What is the fix?

Upvotes: 145

Views: 114381

Answers (11)

koushik v
koushik v

Reputation: 263

I am using MacBook Pro macOS Catalina 10.15.4.

I created a new admin account but the brew was throwing an error.

Hence, I followed a step from this post, what worked is:

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

Upvotes: 12

Uri Meirav
Uri Meirav

Reputation: 3148

The problem kept occurring... after digging deeper I found that only uninstalling Homebrew and then re-installing it solved this issue.

Uninstalling will remove all your brew packages, you can save the output of brew list in a file first, to have a record of what packages were installed.

Uninstall Homebrew:

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

Then re-install it:

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

Upvotes: 257

Ed Mechem
Ed Mechem

Reputation: 41

I'm also on 10.13 High Sierra. I tried the previous suggestions; nothing worked. Eventually I tried installing the command-line tools first:

xcode-select --install

and then afterwards (re-)ran the brew install command:

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

and it finally worked.

Upvotes: 1

Pathak Ayush
Pathak Ayush

Reputation: 756

I did not have the /user/local/Frameworks folder, so this fixed it for me

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

I have OSX High Sierra

Upvotes: 0

Daniel
Daniel

Reputation: 1

Make sure you don't have a lock set on the home folder or any folder an install needs access to.

Even if the permissions and ownership are set correctly and you are currently logged in with a correct user/or Root user it will not allow you to make new folders or directories.

Upvotes: 0

Elle Mundy
Elle Mundy

Reputation: 2217

Try disabling System Integrity Protection. From the documentation:

System Integrity Protection can be configured using the csrutil(1) command.

You can check whether System Integrity Protection is currently enabled on your system by running the following command in the Terminal:

$ csrutil status
System Integrity Protection status: enabled.

To enable or disable System Integrity Protection, you must boot to Recovery OS and run the csrutil(1) command from the Terminal.

Boot to Recovery OS by restarting your machine and holding down the Command and R keys at startup. Launch Terminal from the Utilities menu. Enter the following command: $ csrutil enable

After enabling or disabling System Integrity Protection on a machine, a reboot is required.

Upvotes: 4

Ravi OpenSource
Ravi OpenSource

Reputation: 71

I just run this and everything gets taken care on high sierra:

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

Upvotes: 6

zyqbit
zyqbit

Reputation: 21

if you are using zsh because you come from bash you might have to change your $PATH. you should add export PATH=$HOME/bin:/usr/local/bin:$PATH in .zshrc

then it should work, this problem resolved in my mac by this way.

Upvotes: 2

Reza Farshi
Reza Farshi

Reputation: 1063

You can not change permission for /usr/local itself , but you can change the right permission for folders underneath , so this fixed the
sudo chown -R $(whoami) /usr/local/*

Upvotes: 56

Aayush Gautam
Aayush Gautam

Reputation: 181

I followed this but the problem still persist.
So, I reinstalled homebrew without uninstalling previous one. It's working now!
(I don't know how)

Upvotes: 8

Dan
Dan

Reputation: 2981

Unfortunately you can no longer chown /usr/local in High Sierra. A workaround is to sudo mkdir /usr/local/include and /usr/local/Frameworks if they don't exist, and

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

Thanks to ilovezfs for this simple workaround and for the amazing homebrew!

Upvotes: 69

Related Questions