Skip to content

Instantly share code, notes, and snippets.

@irazasyed
Last active February 24, 2024 04:54
Star You must be signed in to star a gist
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 Dec 7, 2023 via email

@alstjd0051
Copy link

thank you

@ignoracenfly
Copy link

ignoracenfly commented Dec 24, 2023 via email

@VGerris
Copy link

VGerris commented Dec 28, 2023

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

@perth-seo-agency
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)"

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