How to fix brew after OSX upgrade to Yosemite?

I decided to look this up and found that there is an issue. The issue is closed but it is not possible to simply run brew update because you will still get the same error.

So here is what you need to do:

cd /usr/local/Library
git pull origin master

In case you have changes in the directory (/usr/local/Library), the git pull will throw an error. In that case, you'll have to fetch the master branch and set it forcibly as master:

git fetch --all
git reset --hard origin/master

This will upgrade your homebrew and you can use brew again.

If you installed Homebrew as a non-root user, you'll need to cd to /Users/yourusername/homebrew/Library instead of /usr/local/Library.


I found this solution:

That link describes it well, but in case the link goes down, here is what you need to do: Type these commands into your Terminal:

cd /System/Library/Frameworks/Ruby.framework/Versions
sudo ln -s Current 1.8
brew update
sudo rm 1.8

The version and location of Ruby changed with the new Mac OS X version.

To fix this in a generic way, edit /usr/local/Library/brew.rb.

On the first line, replace 1.8 with Current, i.e. from:

#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 

to:

#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0