Skip to content

Instantly share code, notes, and snippets.

@irazasyed
Last active November 16, 2023 08:32
Star You must be signed in to star a gist
Embed
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)/*

@kareemelkasaby1
Copy link

wooooow <3

@alexweissman
Copy link

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

@rtfmoz2
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

@omego
Copy link

omego commented Apr 12, 2022

Thank you!

@erma4ina
Copy link

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/

@mattbieber-lark
Copy link

🙏🙏🙏

@JuCarv-bit
Copy link

thanks! really helpful

@tiganabryan
Copy link

life saver!

@puchkii
Copy link

puchkii commented Jun 9, 2022

tysm🙏🏽

@xyliusun
Copy link

thank you!

@lutabordaMeli
Copy link

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

@dulfrey
Copy link

dulfrey commented Jun 29, 2022

thank you 😁

@Sameto
Copy link

Sameto commented Jul 26, 2022

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

@isobe-h
Copy link

isobe-h commented Aug 1, 2022

thank you!

@gustavolsilvano
Copy link

It worked! Thank you!

@EagleFace5000
Copy link

Youre a genius my friend, thank you!

@carlosmmairena
Copy link

Thank you!

@yezhengli-Mr9
Copy link

my solution with link: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

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

it ":admin" for sum in user

MacOS BigSur 11.4
Thanks~

@philipbankier
Copy link

Thank you ser!

@nnq1
Copy link

nnq1 commented Nov 10, 2022

great, you save my life

@ThorstenClaus
Copy link

In my case I had to setup a new local user on my machine and to remove the old one.
Then the folder ( defined by brew --prefix ) looses its owner.
With this the owner is set to the new local user and - it works!

@hyprcodr
Copy link

In my case, had this problem as I created a new user for development and installed brew in my original Mac OS Monterey user account. The mentioned solution solved my problem. Thanks !

@Emiya0306
Copy link

Nice~ Greate job!

@medwant
Copy link

medwant commented Jun 13, 2023

Thanks! Worked for me (macOS Ventura 13.3.1)

@emivlp
Copy link

emivlp commented Oct 9, 2023

Hi ! how can i fix this
/Users/emvlp/.zprofile:24: permission denied: /opt/homebrew/bin/brew
Could someone tell me the steps?
Thank you so much !

@Tony-MK
Copy link

Tony-MK commented Oct 28, 2023

Thanks @erma4ina

@ignoracenfly
Copy link

ignoracenfly commented Oct 29, 2023 via email

@MrMacvos
Copy link

MrMacvos commented Nov 1, 2023

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

it ":admin" for sum in user

Thanks, this worked for me!

(macOS Ventura 13.9, Intel Mac)

@AndreasMueck
Copy link

Worked for me on Intel Mac with macOS Ventura 13.5. Thank you :)

@ignoracenfly
Copy link

ignoracenfly commented Nov 16, 2023 via email

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