Permission denied - /Library/Caches/Homebrew/Formula/nmap.brewing

MacosHomebrew

Macos Problem Overview


I have created a new user 'dad' on my macbook pro (OSX 10.8.4). 'dad' is an administrator. I've successfully installed homebrew as 'dad'. It was previously installed by another user. I did:

sudo chown -R dad /usr/local/
cd /usr/local/
chmod -R 777 *

But any attempt to install, e.g:

brew install nmap

Gives:

Error: Permission denied - /Library/Caches/Homebrew/Formula/nmap.brewing

It seems nmap.brewing doesn't exist:

dad$ ls -l /usr/local/Library/Caches/Homebrew/Formula/nmap.brewing
ls: /usr/local/Library/Caches/Homebrew/Formula/nmap.brewing: No such file or directory

dad$ ls -l /Library/Caches/Homebrew/Formula/nmap.brewing
ls: /Library/Caches/Homebrew/Formula/nmap.brewing: No such file or directory

Any ideas?

Macos Solutions


Solution 1 - Macos

Fixed.

It seemed I needed to take ownership of /Library/Caches/Homebrew

sudo chown -R $USER /Library/Caches/Homebrew/

Solution 2 - Macos

Searching the brew manpage for /Library/Caches/Homebrew, it turns out that you can set the directory that homebrew uses for caching with the the HOMEBREW_CACHE environment variable, or just create ~/Library/Caches/Homebrew. These approaches will be easier than the chown approach if you’re a non-administrator.

Solution 3 - Macos

I have used the below command:

sudo chmod -R g+w /Library/Caches/Homebrew/Formula/

sudo chgrp -R staff /Library/Caches/Homebrew/Formula/

Solution 4 - Macos

mkdir -p /Library/Caches/Homebrew echo 'export HOMEBREW_CACHE=/Library/Caches/Homebrew' >> ~/.bash_profile source ~/.bash_profile

Solution 5 - Macos

Since user doesn't have permission, just use command

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMike HadlowView Question on Stackoverflow
Solution 1 - MacosMike HadlowView Answer on Stackoverflow
Solution 2 - MacosandrewdotnView Answer on Stackoverflow
Solution 3 - MacosudaiView Answer on Stackoverflow
Solution 4 - MacosmiyakiView Answer on Stackoverflow
Solution 5 - MacosYuriy MedvedevView Answer on Stackoverflow