Skip to content

Instantly share code, notes, and snippets.

@irazasyed
Last active October 3, 2024 14:52
Show Gist options
  • Save irazasyed/7732946 to your computer and use it in GitHub Desktop.
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)/*

@ignoracenfly
Copy link

ignoracenfly commented Feb 29, 2024 via email

@sirkev
Copy link

sirkev commented Mar 22, 2024

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

@sirkev
Copy link

sirkev commented Mar 22, 2024

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

ignoracenfly commented Mar 22, 2024 via email

@HuynhBao171
Copy link

You save my life

@ignoracenfly
Copy link

ignoracenfly commented Apr 24, 2024 via email

@FelipeLemosBellini
Copy link

Thank you, you are amazing

@muh-atta
Copy link

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

Thank you!

@PhillipMwaniki
Copy link

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

ignoracenfly commented May 22, 2024 via email

@ulises-castro
Copy link

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 ...

@keith-hopkins-sada
Copy link

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 ...

This is the [fix] I am looking for.
-Unknown Stormtrooper

Also on Sonoma 14.5, but I think the issue goes back to earlier version of Sonoma for me. I've just been rebooting to clear it, but I like this better.

@ignoracenfly
Copy link

ignoracenfly commented Jun 14, 2024 via email

@bubbleee030
Copy link

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 on Sonoma 14.5, thanks bro

@ignoracenfly
Copy link

ignoracenfly commented Aug 23, 2024 via email

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