Permission denied - /Library/Caches/Homebrew/Formula/nmap.brewing
MacosHomebrewMacos 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