Brew Permission Denied on Mac OS X
This is a common error that might occure while you try to install a brew package or when you try to do a brew link which could say Error: Permission denied
It’s too bad that unless you properly look on the log it outputs on the console, you won’t notice that the brew link has actually failed.
Anyway, what happens most of the time is, When we run an application installation with super user permissions, sometimes it actually modifies the permissions on /usr/local which will they be a problem for a application that’s not running with sudo permissions.
Luckily there’s a easy way to fix this, just run the below commands on terminal and brew should start working properly.
sudo chown -R "$USER":admin /usr/local
Also you might have to run this too in some cases
sudo chown -R "$USER":admin /Library/Caches/Homebrew