others-how to solve '/usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory?' when using pod install in MacOS

1. Purpose

In this post, I would demo how to solve the below exception when using pod install in MacOS

➜  LanrenReceiver1 git:(master) ✗ pod install              
zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory
➜  LanrenReceiver1 git:(master) ✗ ruby -v        
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
➜  LanrenReceiver1 git:(master)

2. Environment

  • Mac OS 10.15
  • Xcode 12

3. The solution

We can solve it as follows:

➜  LanrenReceiver1 git:(master) ✗ brew install cocoapods --build-from-source

➜  LanrenReceiver1 git:(master) ✗ brew link --overwrite cocoapods
Linking /usr/local/Cellar/cocoapods/1.10.1_1... 2 symlinks created.

We use --build-from-source to force homebrew to reinstall the module:

Homebrew is installing module in bottle form (a pre-compiled binary of wxmac). To build from source, add the –build-from-source flag when calling brew install, compile formula from source even if a bottle is provided. Dependencies will still be installed from bottles if they are available

Now try the command again:

➜  LanrenReceiver1 git:(master) ✗ pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 2 dependencies from the Podfile and 11 total pods installed.
➜  LanrenReceiver1 git:(master)

Now it works!

4. Summary

In this post, I demonstrated how to solve the ‘/usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory’ error when using homebrew to install cocoapods.