brew: I cannot uninstall brew or is it safe to disable SIP on MacOS to uninstall brew?

System MacOS:

$ sw_vers -productVersion
10.14.6

Problem:

I want to install tmux with brew. However, when I do it I get an error that directory is not writable.

$ brew install tmux
Error: /usr/local/Cellar is not writable. You should change the
ownership and permissions of /usr/local/Cellar back to your
user account:
  sudo chown -R $(whoami) /usr/local/Cellar
Error: The following directories are not writable

the error also says how to fix it (very nice) but it still gives me the same error “operation is not permitted”.

$ sudo chown -R $(whoami) /usr/local/Cellar
Password:
chown: /usr/local/Cellar/rubberband/1.8.2_1/INSTALL_RECEIPT.json: Operation not permitted
chown: /usr/local/Cellar/rubberband/1.8.2_1/bin/rubberband: Operation not permitted

and then there is this long list of outputs like this one:

chown: /usr/local/Cellar/rubberband/1.8.2_1/README.txt: Operation not permitted

Later I found that uninstalling and reinstalling might fix the problem. But I cannot even uninstall it. I get the same error “operation is not permitted” You need to uninstall and install Homebrew using https://github.com/Homebrew/install _Originally posted by @MikeMcQuaid in https://github.com/Homebrew/brew/issues/3665#issuecomment-357175220_

rm: /usr/local/Cellar: Operation not permitted

the recommendation is to do it manually. But again the same problem.

$ sudo rm -rf /usr/local/Cellar/

rm: /usr/local/Cellar: Operation not permitted

I bet this is something very simple that I am missing.

I have found a recommendation disable System Integrity Protection or SIP. But I don’t like that idea.

“macOS prevents system files from being modified (other than by system updates) using a mechanism called System Integrity Protection, or SIP. It is possible to disable SIP, but this should generally not be necessary, even for developers.” duskwuff -inactive- wrote on https://superuser.com/

Another place still recommends to disable SPI or give permissions to the terminal to access the full disk.

In case you were wondering, yes that does mean there are actually two ways to fix the “Operation not permitted” errors you may encounter in MacOS Terminal; the first which we detail here is rather simple that grants additional access privileges to Terminal app, and the other is a bit more dramatic which involves disabling System Integrity Protection on the Mac which is generally not recommended and we won’t specifically cover here, though simply disabling SIP and rebooting is typically enough to make the error go away if you’d rather go that route.

https://osxdaily.com/2018/10/09/fix-operation-not-permitted-terminal-error-macos/

On the other hand it seems that disabling SIP is not that big of a deal.

If you disable SIP you’ll get the same level of protection as you had with OS X versions before El Capitan. Whether this is enough for your needs it something only you can decide.

OTOH it’s not that much trouble to disable SIP briefly to chance a protected part of the system. If you want to be on the safe side, disconnect from any networks while you do this.

https://apple.stackexchange.com/questions/219161/is-it-safe-to-disable-system-integrity-protection

What would developers of Brew recommend?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Also, in future, please fill out the issue template as given, instead of concocting your own problem description. The stuff I just asked you for is part of that template.