报错信息如下
zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory
尝试升级cocoapods解决,升级步骤如下
- 更新gem,需要强制安装指定目录
$sudo gem update -n /usr/local/bin --system
#下边可忽略,不确定是有意义,因为我之前用brew安装来一下ruby,还更新一下gem源,不知是否有影响
$brew install ruby
$gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
否则报错
ERROR: While executing gem ... (Errno::EROFS)
Read-only file system @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/gem
- 升级cocoapods
$xcode-select --install #1
$sudo gem install -n /usr/local/bin cocoapods --pre #2
不执行1,可能出现的报错
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20201119-9529-1x5y20r.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.13.1/gem_make.out
不执行2中,指定目录**-n /usr/local/bin cocoapods**时,可能出现的报错
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
- 更新仓库
pod repo update
问题解决