Mac OS Yosemite is in the house, but “brew” leaves?

  • Post published:November 12, 2014

Recently I got an undefined error “0”, using brew 0.9.5:

/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 really do not know, why it is Ruby 1.8 (it is very old) being used here, but typing “ruby -version” leads to the fact, that we currently run Ruby of Version 2.0.

So fixing this is pretty simple:

1. Open this file: “/usr/local/Library/brew.rb” (may depend, where exactly you have installed brew to -> see the error message!)

2. Edit the 1st line (replace 1.8 with your current version -> mine = 2.0)
double check, by exploring your folder (System/Library/Frameworks/Ruby.framework/Versions/)

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

[UPDATE]
In general errors with ruby and brew can often be fixed with:
1. Clean old brew:  rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
2. Remove brew the hard way:  sudo rm -f `which brew`
3. Reinstall brew:  ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”