Apple - How to repair and/or reinstall Homebrew safely?
This happened to me because I had two tabs open in my console. In Console A I removed the current working directory of Console B. Then, without thinking about it, I ran brew upgrade
in Console B. Of course it threw the above error.
Simple solution: just cd
to a different directory in Console B and brew upgrade
again.
Me and my infinite wisdom.
Why don't you do what it says?
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The first line is going to delete homebrew completely and then you should be able to reinstall it.
NOTE: If you do this you'll have to reinstall all the things you installed via homebrew.