Skip to content

Instantly share code, notes, and snippets.

@irazasyed
Last active September 1, 2026 14:20
Show Gist options
  • Select an option

  • Save irazasyed/7732946 to your computer and use it in GitHub Desktop.

Select an option

Save irazasyed/7732946 to your computer and use it in GitHub Desktop.
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

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

@nnq1

nnq1 commented Nov 10, 2022

Copy link
Copy Markdown

great, you save my life

@ThorstenClaus

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

Nice~ Greate job!

@syazwan-sa

Copy link
Copy Markdown

Thanks! Worked for me (macOS Ventura 13.3.1)

@emivlp

emivlp commented Oct 9, 2023

Copy link
Copy Markdown

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

Tony-MK commented Oct 28, 2023

Copy link
Copy Markdown

Thanks @erma4ina

@ignoracenfly

ignoracenfly commented Oct 29, 2023 via email

Copy link
Copy Markdown

@MrMacvos

MrMacvos commented Nov 1, 2023

Copy link
Copy Markdown

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
Copy Markdown

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

@ignoracenfly

ignoracenfly commented Nov 16, 2023 via email

Copy link
Copy Markdown

@daveqs

daveqs commented Dec 7, 2023

Copy link
Copy Markdown

Worked for me on Monterey 12.6.5! (Late 2016, Intel silicon)

@ignoracenfly

ignoracenfly commented Dec 7, 2023 via email

Copy link
Copy Markdown

@asyncFlow-dad

Copy link
Copy Markdown

thank you

@ignoracenfly

ignoracenfly commented Dec 24, 2023 via email

Copy link
Copy Markdown

@VGerris

VGerris commented Dec 28, 2023

Copy link
Copy Markdown

Although this works, this is BAD solution.
The brew prefix $(brew --prefix) is /usr/local and that directory should be accessible for all users on the system.
With only one user, setting that to the current user is no problem, but as soons as a second user is added, this does not work and breaks all the permissions for it.
The proper way to do it is to have the installer use a group and make any user that needs access a member of it, so it works for multiple users.

The group on most folders is admin so adding a user to the admin group and making sure permissions between group and user are the same at least for directories brew uses should fix this.

The command to add user john to group admin is
sudo dseditgroup -o edit -a john -t user admin

@danielemeryseo

Copy link
Copy Markdown

None of the above worked for me. Keep getting permissions errors when updating homebrew.

Example Permission Denied Error:

/Users/{insert username}/Library/Caches/Homebrew/api/formula_names.before.txt: Permission denied
The solution that worked was just deleting the cache files:

sudo rm -rf ~/Library/Caches/Homebrew/

Additionally, ran the following for good measure:

sudo chown -R {your username}:admin ~/Library/Caches/Homebrew/
sudo chmod -R 755 ~/Library/Caches/Homebrew/

Then reinstall Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

@gao1143632516

Copy link
Copy Markdown

be of use

@ignoracenfly

ignoracenfly commented Feb 29, 2024 via email

Copy link
Copy Markdown

@sirkev

sirkev commented Mar 22, 2024

Copy link
Copy Markdown

thank you, the first solution worked for me on my headless macOS Catalina (version 10.15) ci server

@sirkev

sirkev commented Mar 22, 2024

Copy link
Copy Markdown

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

the command changes the ownership of all files and directories within the Homebrew installation directory to the current user, effectively giving the current user full control over these files and directories.

i'm just coming from linux, it didn't hit me that could be the problem. like mention above this will break when you add another user. the solution by @VGerris would be much better if potentially you'd want to have other users in the system

@ignoracenfly

ignoracenfly commented Mar 22, 2024 via email

Copy link
Copy Markdown

@HuynhBao171

Copy link
Copy Markdown

You save my life

@ignoracenfly

ignoracenfly commented Apr 24, 2024 via email

Copy link
Copy Markdown

@FelipeLemosBellini

Copy link
Copy Markdown

Thank you, you are amazing

@muh-atta

Copy link
Copy Markdown

None of the above worked for me. Keep getting permissions errors when updating homebrew.

Example Permission Denied Error:

/Users/{insert username}/Library/Caches/Homebrew/api/formula_names.before.txt: Permission denied The solution that worked was just deleting the cache files:

sudo rm -rf ~/Library/Caches/Homebrew/

Additionally, ran the following for good measure:

sudo chown -R {your username}:admin ~/Library/Caches/Homebrew/
sudo chmod -R 755 ~/Library/Caches/Homebrew/

Then reinstall Homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Worked for me. thank you!

@gregd100

Copy link
Copy Markdown

Thank you!

@PhillipMwaniki

Copy link
Copy Markdown

None of the above worked for me. Keep getting permissions errors when updating homebrew.

Example Permission Denied Error:

/Users/{insert username}/Library/Caches/Homebrew/api/formula_names.before.txt: Permission denied The solution that worked was just deleting the cache files:

sudo rm -rf ~/Library/Caches/Homebrew/

Additionally, ran the following for good measure:

sudo chown -R {your username}:admin ~/Library/Caches/Homebrew/
sudo chmod -R 755 ~/Library/Caches/Homebrew/

Then reinstall Homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Best fix. This worked for me on Monterey v12.6.3

@ignoracenfly

ignoracenfly commented May 22, 2024 via email

Copy link
Copy Markdown

@ulises-castro

Copy link
Copy Markdown

Hi, for my case the error was Error: Permission denied @ dir_s_mkdir - /private/tmp/homebrew....

And the solution was

sudo chown $(whoami):admin /private/tmp/

I just updated to MacOs Sonoma 14.5, I do not know if that was the case ...

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