Brew Problems on Mac On my mac OSX Yosemite.

when I do a  brew update

error: unable to unlink old 'bin/brew' (Permission denied)
error: unable to unlink old 'share/man/man1/brew.1' (Permission denied)


OK. So I do a sudo brew update

MacBook-Pro:bin$ sudo brew update
Password:
Error: Cowardly refusing to `sudo brew update`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.


So it doesn't let me run the update in any way.
Try this:

sudo chown -R $USER /usr/local; brew update