You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS Catalina 10.15下React Native的pod install失败及Ruby解释器错误求助

Fixing "bad interpreter: No such file or directory" for pod install on macOS Catalina 10.15 with React Native

Hey there, I’ve dealt with this exact headache on Catalina before—let’s break down why this happens and how to fix it for good.

Why this error pops up

macOS Catalina removed the system-provided Ruby 2.3 that your React Native/CocoaPods setup is trying to reference. The path /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby no longer exists, hence the "bad interpreter" error.

I’ll start with the most robust fixes (these prevent future Ruby-related issues too):

Option 1: Use rbenv to manage Ruby versions (my go-to)

rbenv is a lightweight tool that lets you switch between Ruby versions without messing with system files.

  • Install rbenv via Homebrew:
    brew install rbenv
    
  • Initialize rbenv so it loads in your terminal sessions:
    rbenv init
    
    Follow the on-screen instructions to add the required line to your ~/.zshrc (Catalina’s default shell) or ~/.bash_profile.
  • Restart your terminal or reload the config:
    source ~/.zshrc
    
  • Install a Ruby version compatible with Catalina and CocoaPods (2.7.x works great):
    rbenv install 2.7.6
    
  • Set this as your global default Ruby:
    rbenv global 2.7.6
    
  • Verify the change with:
    ruby --version
    
  • Reinstall CocoaPods to use the new Ruby:
    gem install cocoapods
    
  • Head back to your React Native project’s ios directory and run:
    pod install
    

Option 2: Install Ruby via Homebrew (simpler if you don’t need version switching)

If you don’t want a version manager, you can install Ruby directly with Homebrew:

  • Install Ruby:
    brew install ruby
    
  • Update your shell’s PATH to prioritize Homebrew’s Ruby over the system one. Open ~/.zshrc in a text editor and add this line at the top:
    export PATH="/usr/local/opt/ruby/bin:$PATH"
    
  • Reload the config:
    source ~/.zshrc
    
  • Check your Ruby version to confirm it’s the Homebrew one:
    ruby --version
    
  • Reinstall CocoaPods and run pod install as above.

Option 3: Quick temporary fix (not recommended long-term)

If you need a quick workaround (but this might break other tools later), you can update the script that’s calling the old Ruby path:

  • Find the path to your current working Ruby with:
    which ruby
    
  • Locate the script throwing the error (usually a CocoaPods or React Native script in your project’s ios directory) and open it in a text editor.
  • Replace the shebang line at the top (looks like #!/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby) with the path you got from which ruby.
  • Save the file and try pod install again.

Extra Tips

  • If you run into permission errors, avoid using sudo—the version manager or Homebrew methods should install Ruby/CocoaPods in your user directory, so sudo isn’t needed.
  • If pod install still acts up, try cleaning your CocoaPods cache first:
    pod deintegrate
    pod install
    

Let me know if any of these steps hit a snag—I can help troubleshoot further!

内容的提问来源于stack exchange,提问作者Sagar Kachhadiya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:19:18