Getting a “bad interpreter” error when using brew

I got this error (much the same):

/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

and fixed by the solution below:

  1. Open brew.rb:

    $ sudo vim /usr/local/Library/brew.rb
    
  2. Change the first line’s 1.8 to Current:

    Before:

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

    After:

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

Then brew works for me. Hope it helps if any other one got this issue. 🙂


If you get the error

Homebrew requires Leopard or higher. For Tiger support, see:
https://github.com/mistydemeo/tigerbrew

change the MACOS check from <10.5 to <10.

Tip by @TimCastelijns:

10.5 doesn’t work because in comparison, it’s higher than 10.10 (.1 vs .5). I added a check (and MACOS_VERSION != 10.10) instead of lowering from 10.5 to 10.

Leave a Comment