Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Ruby / Homebrew / RVM to work on Yosemite?

This error can easily be fixed in the following steps:

1) Open terminal

2) Type nano /usr/local/Library/brew.rb

3) In the first line change “1.8″ to “Current”, so it should look like this:

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

via http://blog.ic3man.gr/2014/06/homebrew-ruby-bad-interpreter-no-such-file-or-directory/


I updated to Yosemite and later found out brew was broken.

/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

If you haven't made any changes to brew yet, here is what I recommend. Otherwise read further below.

  1. cd /System/Library/Frameworks/Ruby.framework/Versions/
  2. sudo ln -s Current 1.8
  3. brew update
  4. sudo unlink 1.8

Already made changes to brew files and stuck in a git mess?

I tried to edit /usr/local/Library/brew.rb but the local change to my git repo was preventing brew update from pulling down updates. I tried some other solutions mentioned on this page and from other sites and I ended up with a git mess and all I wanted to do was undo everything I had done to brew.

I committed my change but it made things worse. Eventually I had to undo my commits and git reset --hard HEAD~1 until I was at the right commit-ish. I had a mess of unversioned files too (I changed files permissions in /usr/Local) so I did a git clean -f -d which removed all unversioned files and directories and got me back to where I started before I made any changes.


Steps to fix it:

  1. Install command line tools for Xcode 6

  2. Reinstall brew:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  3. Once brew is installed, rvm will work:

    rvm install ruby
    

Worked for me, yahoo!


Editing the script means brew update won't work; there are local edits to tracked files which causes the git pull to fail.

I did this, which I suspect is cleaner:

cd /usr/local/Library
git pull -q origin refs/heads/master:refs/remotes/origin/master

There are no complaints from brew doctor.


This is a conglomeration from answers from other people's posts as well as a bit of digging on Google, but I figured I'd put it up so a complete answer is in one place. Specifically this gets things to work now, but also lets you do brew updates as normal and gets everything clean again.

  1. Open /usr/local/Library/brew.rb (emacs/vi/nano/whatever)
  2. Change the first line to read: #!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0. You're just changing the "1.8" that was in that line to "Current" (make sure you keep the capital "C" otherwise git will get confused later).
  3. cd $(brew --repository)
  4. git add Library/brew.rb
  5. git commit -m "upgrading to ruby 2.0"
  6. brew update (or sudo brew update if your brew is setup to only do system changes with sudo)

Credit: a lot of this came from here, though I really recommend against doing git commit -am in your /usr/local folder.