Getting a “bad interpreter” error when using brew

前端 未结 12 1408
半阙折子戏
半阙折子戏 2020-12-01 14:13

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/rub         


        
相关标签:
12条回答
  • 2020-12-01 14:31

    At the risk of oversimplifying things, try running

    gem install bundler
    

    I was transitioning my Ruby environment from RBENV to RVM and it worked for me.

    0 讨论(0)
  • 2020-12-01 14:34

    Fix:

    sudo gem install cocoapods
    
    0 讨论(0)
  • 2020-12-01 14:40

    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.

    0 讨论(0)
  • 2020-12-01 14:40

    None of the above worked for me, so I kept browsing and found this answer, https://stackoverflow.com/a/24225960/1359088 which did fix brew for me. He says in step 1 to install XCode 6 command line tools, but doesn't say how; use this command:

    xcode-select --install
    
    0 讨论(0)
  • 2020-12-01 14:43

    This happened because I needed to update brew - in the updated version it already uses Current ruby

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

    This solved the problem

    0 讨论(0)
  • 2020-12-01 14:44

    You need to change the path for Ruby.Framework

    I solved it with commands as mentioned.

    1. brew install cocoapods --build-from-source

    2. brew link --overwrite cocoapods

    If you have a lower version below Xcode 11, you have to remove it before you use the above commands.

    Reference: Ruby Framework issue

    0 讨论(0)
提交回复
热议问题