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

Solution 1:

Fixed.

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

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

Solution 2:

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.