How to repair Homebrew permissions after installing as root?
Reset the permissions of /usr/local and Homebrew's caches to the current user:

sudo chown -R $USER:admin /usr/local /Library/Caches/Homebrew