pod install するとエラーが起きる時の対応

環境

  • macOS Big Sur
  • zsh

pod install できない

下記エラーが出た。
macOS をアップデートする度に出る気がする。

$ 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

$ pod --version
zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory

$ pod
zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory

解決方法

最後エラーがでるけど無視する。

$ sudo gem update --system -n /usr/local/bin

Password:
Updating rubygems-update
Fetching rubygems-update-3.2.11.gem
Successfully installed rubygems-update-3.2.11
Parsing documentation for rubygems-update-3.2.11
Installing ri documentation for rubygems-update-3.2.11


Installing darkfish documentation for rubygems-update-3.2.11
Done installing documentation for rubygems-update after 364 seconds
Parsing documentation for rubygems-update-3.2.11
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.2.11
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/gem

cocoapods をインストールする

$ sudo gem install cocoapods -n /usr/local/bin

Password:
Fetching colored2-3.1.2.gem
Fetching nanaimo-0.3.0.gem
Fetching atomos-0.1.3.gem
...

バージョン確認

$ pod --version
1.10.1