I came across several homebrew issues where symlinks couldnt be created due to permission denied errors.
TL;DR:
reset permissions to the /usr/local stack.

The command will fix the permission error
sudo chown -R `whoami` /usr/local
源链接

Hacking more

...