chown: /usr/local: Operation not permitted

I am trying to get homebrew working on my macOS high sierra machine. It will not run because there is a permissions issue. When I run `brew doctor`, I get the following message;


run the following command to fix permissions: "sudo chown -R $(whoami) /usr/local"


When I try to run the chown, I am getting the following error;


"chown: /usr/local: Operation not permitted"


Bueller?

Is your account admin?

It is the regular user account, but It is the one I created when I set up this Mac. I have to elevate my priveldges with `sudo` when I am installing something onto the system or changing permissions.

Tried it here, it is working for me.

I'm seeing this as well with a fresh install of 10.13 (17A315i) in a VM with an APFS root filesytem:

Michaels-Mac:~$ sudo chown mike /usr/local
chown: /usr/local: Operation not permitted
Michaels-Mac:~$ ls -lO /usr
total 0
drwxr-xr-x  975 root  wheel  restricted 31200  2 Aug 01:56 bin
drwxr-xr-x  262 root  wheel  restricted  8384  1 Aug 06:31 include
drwxr-xr-x  309 root  wheel  restricted  9888  1 Aug 06:32 lib
drwxr-xr-x  233 root  wheel  restricted  7456  2 Aug 01:56 libexec
drwxr-xr-x   14 root  wheel  sunlnk       448  1 Aug 06:58 local
drwxr-xr-x  246 root  wheel  restricted  7872  1 Aug 05:54 sbin
drwxr-xr-x   46 root  wheel  restricted  1472  1 Aug 05:54 share
drwxr-xr-x    5 root  wheel  restricted   160 21 Jul 17:51 standalone

Might be a new policy.

I would try disabling sip, changing it, and then reenabling.


I use /usr/local with a hidden account 'brew' and 'su brew' to manage homebrew. Only the folder used by brew are under that account's control.

So we've come across a bug related to this that seems new to 10.13:


If you take two 10.13 b4 systems -- and you target boot one of them -- and then you install something that would install to /usr/local (like Munki) to the Target-booted drive...


/usr changes from "sunlnk" to "restricted".


This seems like a new bug in 10.13 -- older OSes do not do that. Bug filed. It's a pain for us as we use AutoDMG to make images for deployment that contain Munki...

Hi!


I don't know if what I did was stupid, but I installed Homebrew again - without uinstalling the previous version - and now it is working.

This works for me as well. Thx

Strange, but it also works for me; Many Thx

I was also getting the same error when I was using brew to install something. Then searched about the problem on internet and got to know that it is something to do with the ownership. In my mac there are two administrative accounts one which I am using to install is one of them even then I was facing the same problem so I decided to shift another administrative account to standard account but doing that doesn't solved this problem then I decided to use chown command to change my ownership but got chown: /usr/local: Operation not permitted

There a point that you know keep in mind to avoid getting this problem ie: You should be using Adminstrative account. If you are getting this problem with Administrative account please reinstall homeBrew using this command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

everything will work now. It worked for me My macos is BigSur

On Monterey, running /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" results in the same "Operation not permitted" errors when the install script tries to make directories in /usr/local/ group writable.

chown: /usr/local: Operation not permitted
 
 
Q