7

I am unable to do brew update because I can’t chown /usr/local:

$ brew update
Error: /usr/local is not writable. You should change the ownership
and permissions of /usr/local back to your user account:
  sudo chown -R $(whoami) /usr/local

based on this: https://github.com/Homebrew/brew/issues/385

I tried these 2 chown command but it didnt work:

$ sudo chown -R $(whoami) $(brew --prefix)
chown: /usr/local: Operation not permitted


$ sudo chown -R $(whoami) /usr/local
chown: /usr/local: Operation not permitted

Here is my /usr/local listing:

$ cd /usr/local
$ ls -al
total 56
drwxr-xr-x 23 root wheel 736 Dec 2 15:24 .
drwxr-xr-x@ 9 root wheel 288 Oct 26 00:22 ..
-rw-r--r-- 1 megasap wheel 0 Dec 2 15:11 .com.apple.installer.keep
drwxr-xr-x 16 megasap admin 512 Jan 11 14:08 .git
drwxr-xr-x 5 megasap admin 160 Dec 2 15:24 .github
-rw-r--r-- 1 megasap admin 1112 Aug 11 2016 .gitignore
-rw-r--r-- 1 megasap admin 253 Aug 11 2016 .travis.yml
-rw-r--r-- 1 megasap admin 291 Aug 11 2016 .yardopts
-rw-r--r-- 1 megasap admin 3161 Aug 11 2016 CODEOFCONDUCT.md
drwxr-xr-x 35 megasap admin 1120 Jan 11 11:35 Cellar
-rw-r--r-- 1 megasap admin 1241 Jan 26 2016 LICENSE.txt
drwxr-xr-x 9 megasap admin 288 Dec 2 15:25 Library
-rw-r--r-- 1 megasap admin 5451 Aug 11 2016 README.md
drwxr-xr-x 262 megasap admin 8384 Jan 11 23:09 bin
drwxr-xr-x 11 megasap admin 352 Dec 2 15:25 etc
drwxr-xr-x 57 megasap staff 1824 Dec 2 15:25 include
drwxr-xr-x 102 megasap staff 3264 Dec 2 15:25 lib
drwx------ 4 megasap wheel 128 Dec 2 15:24 libexec
drwxr-xr-x 3 megasap admin 96 Dec 2 15:23 n
drwxr-xr-x 34 megasap admin 1088 Dec 2 15:25 opt
drwxr-xr-x 8 megasap admin 256 Dec 2 15:24 sbin
drwxr-xr-x 16 megasap admin 512 Dec 2 15:25 share
drwxr-xr-x 8 megasap admin 256 Dec 2 15:25 var

I'm using macOS 10.13.1 high sierra.

bfontaine
  • 18,169
  • 13
  • 73
  • 107
Axil
  • 3,606
  • 10
  • 62
  • 136
  • Possible duplicate of [can't chown /usr/local for homebrew in OSX 10.13 High Sierra](https://stackoverflow.com/questions/46459152/cant-chown-usr-local-for-homebrew-in-osx-10-13-high-sierra) – bfontaine Feb 08 '18 at 13:23

5 Answers5

10

Reinstalling Homebrew worked for me

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
ldeluca
  • 934
  • 3
  • 12
  • 25
  • Expect to get `Error: The Ruby Homebrew installer is now disabled and has been rewritten in Bash. Please migrate to the following command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` – Will Oct 02 '22 at 15:01
6

You may want to try:

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

For more see: https://github.com/Homebrew/brew/issues/3228

Raja Rao
  • 5,691
  • 2
  • 28
  • 31
1

On Mac, I have to give "Full Disk Access" to the terminal using the below page -

https://macreports.com/terminal-says-operation-not-permitted-on-mac-fix/

Rahul Satal
  • 2,107
  • 3
  • 32
  • 53
0

Apparently this is due to mac's "system integrity configuration". To get around this you need to reboot your machine into recovery mode (restart your machine and hold down ⌘+R) go into Utilities > Terminal and type the command:

csrutil disable
reboot

And then run your chown command. I guess its recommended to reenable this after changing permissions to re-enable the security.

Full disclosure, I haven't tried this myself - I'll give it a go later today since its a massive PITA. For the record, I'm only attempting to install python3.

Original information

Boomer Rogers
  • 965
  • 10
  • 17
-3

uninstall and install Homebrew using https://github.com/Homebrew/install

Axil
  • 3,606
  • 10
  • 62
  • 136