Here's what I did to force Homebrew to run as root:
cd /usr/local/Homebrew/Library/Homebrew
Edit brew.sh, look for "Running Homebrew as root is extremely dangerous and no longer supported" (line 250 in my version), delete the check.
Did exactly that by temporary just returning in function check-run-command-as-root() in /usr/local/Homebrew/Library/Homebrew/brew.sh
. Worked (some symlink related problems got fixed) and changed back. No more problems since then.
Worked on Monterey.
Was getting
Error: Could not cleanup old kegs! Fix your permissions on:
/usr/local/Cellar/php@7.4/7.4.16
/usr/local/Cellar/php@7.4/7.4.24
wooooow <3
I'm really expected to recursively change ownership of my entire usr/local
directory just because Homebrew told me to? A directory shared by all sorts of other applications and services? Ridiculous
Homebrew needs to work with the systems it is installing itself on. If there are permission issues then it needs to suggest sudo commands to the user that cover its specific requirements. Better yet provide a script for users to run under sudo to pre-create the dirs set permissions prior to install.
The closest I could come up with is the following. This make use of the users default group setting so other users can install homebrew utilities as well. Replace $GID if you want to use a different group, admin is a common one.
for name in Cellar Cask Homebrew Frameworks; do [ ! -d $name ] && sudo install -d -g $GID -m 0775 /usr/local/$name; done
Thank you!
Was getting
erma4inapower@MacBook-Pro-Dmitrij ~ brew services start php
Error: Permission denied @ rb_sysopen - /Users/erma4inapower/Library/LaunchAgents/homebrew.mxcl.php.plist
Ended up:
sudo chown -R $(whoami) /Users/erma4inapower/Library/LaunchAgents/
thanks! really helpful
life saver!
tysm🙏🏽
thank you!
thank you !!! what exactly did I just do ???
thank you
Well I ran this command:
as well as:
And now I regret it. It's a security faux pas for the reasons others have said.
How do I change the ownership and permissions of /usr/local (and all subfolders and their contents) back to the factory defaults?
I'm running High Sierra.
Many thanks.