183

I faced some issue with Homebrew. I upgraded to Yosemite. After the upgrade, homebrew seems to be broken.

I would run any brew command and get this 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 26: /usr/local/Library/brew.rb: Undefined error: 0

How to resolve it?

1
  • I just upgraded from Mac OS X 10.8 to 10.10 (Yosemite), and homebrew works fine after the upgrade. Either this problem was fixed, or there was something different about my OS upgrade compared to everyone else posting here.
    – Yitz
    Commented Apr 8, 2015 at 14:50

5 Answers 5

240

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.

16
  • 20
    yet another reason I love having a package manager built on git :)
    – spinlock
    Commented Nov 3, 2014 at 17:48
  • 3
    Exactly. Love software that simply runs from source and upgradable through git pull Commented Nov 4, 2014 at 7:34
  • 7
    Weird, I'm getting this fatal: Not a git repository (or any of the parent directories): .git
    – Gabriel R.
    Commented Nov 24, 2014 at 10:48
  • 2
    I'm getting this error: error: cannot open .git/FETCH_HEAD: Permission denied
    – sixty4bit
    Commented Nov 25, 2014 at 3:40
  • 6
    Try sudo git pull origin master Commented Nov 25, 2014 at 4:10
48

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
6
  • 2
    Unlike the accepted answer this actually worked.
    – Paul
    Commented Jan 8, 2015 at 22:17
  • This is the only thing that worked for me on 10.10.3
    – user
    Commented Apr 23, 2015 at 5:58
  • Also works for 10.10.4
    – Ralfonso
    Commented Apr 30, 2015 at 1:21
  • Aborting Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
    – itsazzad
    Commented May 30, 2015 at 7:26
  • This worked for me, though there was also another step to take: stackoverflow.com/questions/26501126/…
    – JussiR
    Commented Jun 21, 2015 at 18:07
22

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
2
  • This breaks brew update because you now have an uncommitted change. Commented Nov 28, 2014 at 0:58
  • 1
    …but to do brew update one has to apply the fix I suggested.I never used brew update until now, so I didn't even have the repo initialized. Can't remember how I even installed it.
    – Gabriel R.
    Commented Nov 28, 2014 at 11:18
3

If you fix the ruby problem and then hit a problem where you are told that the system thinks you are running tiger or an older release, the fix for that is here

1

I first tried the highest rated answer an then hit another issue. After that I kind of gave up on fixing it since I had just a couple packages installed. Maybe others are in this boat as well.

While these are all excellent answers, for me it was simpler to just to re-install brew.

First, I ran the instructions on:

http://brew.sh/

which directed me to first uninstall, and printed a command line. I ran that command line to uninstall, then re-installed, and everything was fine.

I don't want to print the specific commands, as they tend to change a bit as brew adjust how things are installed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .