After installing OSX 10.10 Yosemite Beta my Homebrew gave the following error:

/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0

I solved it by doing a complete reinstall, but also found another fix if you want to do a manual update.

The easy way (reinstall):

  • Save a list of your currently installed binaries into a Brewfile
ls -1 /usr/local/Cellar > ~/Desktop/Brewfile && sed i.bak 's/^/install /' ~/Desktop/Brewfile
  • Remove the old Homebrew
rm -rf /usr/local/Cellar /usr/local/.git
  • Reinstall homebrew like normal
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
  • If you're using brew-cask, re-add the tap
brew tap caskroom/cask
  • And re-brew based on the Brewfile
cd ~/Desktop
brew bundle

If you get the following error when running brew bundle:

Error: Command failed: L1:brew install xxx

Then go through the Brewfile manually

cat Brewfile | xargs -I {} sh -x -c "brew {}"

The hard way (manual upgrade)

See another fix.