Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

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

Copy link

Qlub53 commented Aug 27, 2021

after upgrading to High Sierra, uninstall brew & re-install with the below command to ensure the linking to the brew github and associated permissions to the local folder work correctly:

/usr/bin/ruby -e "$(curl -fsSL"

For real? Didn't work as expected at all on macOS Catalina...
How come reinstalling fixed the problem?
I still winded up having the same permission denial.

Copy link

Qlub53 commented Aug 27, 2021

my solution with link: /usr/bin/ruby -e "$(curl -fsSL"

and command: sudo chown -R "$(whoami)":admin /usr/local

it ":admin" for sum in user

MacOS BigSur 11.4

Chances are it's your sudo chown bit that saved you
Reinstallation probably was never part of the equation

Copy link

applebait commented Sep 11, 2021

Is there a safe solution for my scenario?
All the clients (Macs) are in a network where all the users are logged through AD on a Windows server. Every machine has its admin user. How can I get rid of permission errors in this environment? I wouldn't like to mess up by giving permissions to these network users, they are managed as they should by other softwares and systems, such as the AD and the Avid managers (Interplay and NEXIS).

Copy link

dandgerson commented Oct 6, 2021

No need to chown the whole /usr/local if brew only fails to create a single directory.

For example, I fixed this error:

Permission denied @ dir_s_mkdir - /usr/local/Frameworks

With this command:

sudo install -d -o $(whoami) -g admin /usr/local/Frameworks

Thanks -- it's work for me

Copy link

santiagoarizti commented Oct 14, 2021

my solution with link: /usr/bin/ruby -e "$(curl -fsSL"
and command: sudo chown -R "$(whoami)":admin /usr/local
it ":admin" for sum in user
MacOS BigSur 11.4

Chances are it's your sudo chown bit that saved you Reinstallation probably was never part of the equation

@Qlub53 I first did the sudo chown part, didn't work, I then proceeded to reinstall, and my problems were gone :)

Thanks @aether2501

Copy link

ipcm27 commented Oct 18, 2021

"sudo chown -R $(whoami) $(brew --prefix)/*"
Worked just fine for me. But can Anyone explain why there's people saying that this is a terrible solution and that they are going to Macports?

Copy link

fabswt commented Oct 27, 2021

Trying to run a brew cleanup, I kept getting errors like this one, exclusively with .DS_Store files:

Error: Permission denied @ apply2files - /usr/local/lib/prey/versions/1.9.12/node_modules/sqlite3/lib/.DS_Store

Ended up using simply:

cd /usr/local/lib/
sudo find . -name ".DS_Store" -delete

And the next brew cleanup ran fine.

Copy link

snowquirk commented Nov 9, 2021

Thanks!!! @mihkell
It works for MacOS BigSur 11.4

Copy link

gord288 commented Nov 12, 2021

Well I ran this command:

sudo chown -R $(whoami) /usr/local

as well as:

chmod u+w /usr/local

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.

Copy link

rolf-langer commented Nov 27, 2021

Here's what I did to force Homebrew to run as root:
cd /usr/local/Homebrew/Library/Homebrew
Edit, 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/ Worked (some symlink related problems got fixed) and changed back. No more problems since then.

Copy link

tiagomatosweb commented Feb 26, 2022

Worked on Monterey.

Was getting

Error: Could not cleanup old kegs! Fix your permissions on:

Copy link

kareemelkasaby1 commented Mar 17, 2022

wooooow <3

Copy link

alexweissman commented Mar 29, 2022

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

Copy link

rtfmoz2 commented Apr 4, 2022

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

Copy link

omego commented Apr 12, 2022

Thank you!

Copy link

erma4ina commented Apr 19, 2022

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/

Copy link

mattbieber-lark commented Apr 30, 2022


Copy link

JuCarv-bit commented Jun 6, 2022

thanks! really helpful

Copy link

tiganabryan commented Jun 7, 2022

life saver!

Copy link

puchkii commented Jun 9, 2022


Copy link

xyliusun commented Jun 14, 2022

thank you!

Copy link

lutabordaMeli commented Jun 21, 2022

thank you !!! what exactly did I just do ??? 🤔🤔🤔 you saved my lifeee

Copy link

dulfrey commented Jun 29, 2022

thank you 😁

Copy link

Sameto commented Jul 26, 2022

This just save my bacon... Thanks a lot...

Copy link

isobe-h commented Aug 1, 2022

thank you!

Copy link

gustavolsilvano commented Aug 10, 2022

It worked! Thank you!

Copy link

EagleFace5000 commented Aug 11, 2022

Youre a genius my friend, thank you!

Copy link

carlosmmairena commented Aug 12, 2022

Thank you!

Copy link

yezhengli-Mr9 commented Aug 21, 2022

my solution with link: /usr/bin/ruby -e "$(curl -fsSL"

and command: sudo chown -R "$(whoami)":admin /usr/local

it ":admin" for sum in user

MacOS BigSur 11.4

Copy link

philipbankier commented Aug 24, 2022

Thank you ser!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment