Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
669 views
in Technique[技术] by (71.8m points)

ruby on rails - Getting a "bad interpreter" error when using brew

I'm getting this error when I try to run any brew command.

Holger-Sindbaeks-MacBook-Air:~ holgersindbaek$ brew help
-bash: /usr/local/bin/brew: /usr/bin/ruby: bad interpreter: No such file or directory

I have absolutely no idea on how to fix this and been searching for a long time without answer.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...