How to repair Homebrew after OS X upgrade
I was getting the following error when running brew after the latest upgrade to OS X (El Capitan).
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
I couldn't even run brew update - arg.
This is what I did to correct the issue - git to the rescue!
cd /usr/local/Library
git pull origin master
git pull will throw an error if you have changes in the directory (/usr/local/Library). If so, you'll have to fetch the master branch and perform a hard reset.
git fetch --all
git reset --hard origin/master
You should be able to now use brew again - hurrah!
Note: in the event you installed Homebrew as a non-root user, you'll need to cd to /Users/non-root-user-rname/homebrew/Library instead of /usr/local/Library.