升级 pod 遇到问题的解决办法

一句正常的更新pod命令

sudo gem install -n /usr/local/bin cocoapods
正常情况下, 执行上面的命令 就可以直接升级成功, 升级成功万事大吉,

反之就遇到下面的升级失败的情况!

➜ Ruby: sudo gem install -n /usr/local/bin cocoapods
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.3.0/gems/ffi-1.12.2/ext/ffi_c

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200313-24412-3logr3.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out
这个升级问题困扰了好多天, 可能是ruby的版本和最新的pod版本兼容性有问题, 所以必须先升级ruby, 才能升级pod成功, 且看下面:

方法是在stackoverflow找到的, 当然在安装过程中还需要解决一些其他的异常问题 (默认大家已经安装了 xcode-select)

  1. 安装 rvm

curl -L https://get.rvm.io | bash -s stable
如果可以安装成功并出现下列的提示则可以直接进行第二步

Upgrade of RVM in /Users/mengshun/.rvm/ is complete.

Thanks for installing RVM
Please consider donating to our open collective to help us maintain RVM.

Donate: https://opencollective.com/rvm/donate

如果失败, 出现了下方的错误(报错内容 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation timed out)

➜ Ruby: curl -L https://get.rvm.io | bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 194 100 194 0 0 166 0 0:00:01 0:00:01 --:--:-- 166
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
执行下列的指令

sudo gem install redis
然后继续执行rvm的安装命令 (curl -L https://get.rvm.io | bash -s stable)

如果还是报 443 错误, 那就等一会再执行, 多次重试 总会成功的(我自己试了3次)

  1. 安装 ruby 2.6

➜ Ruby: rvm install ruby-2.6
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.14/x86_64/ruby-2.6.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Homebrew libs 'coreutils libyaml [email protected] readline' require update - skipping.
Skipping update of certificates bundle '/usr/local/etc/[email protected]/cert.pem', to force update run:
rvm osx-ssl-certs update /usr/local/etc/[email protected]/cert.pem

Requirements installation successful.
Installing Ruby from source to: /Users/mengshun/.rvm/rubies/ruby-2.6.3, this may take a while depending on your cpu(s)...
ruby-2.6.3 - #downloading ruby-2.6.3, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13.8M 100 13.8M 0 0 9172 0 0:26:21 0:26:21 --:--:-- 11855
ruby-2.6.3 - #extracting ruby-2.6.3 to /Users/mengshun/.rvm/src/ruby-2.6.3 - please wait
ruby-2.6.3 - #configuring - please wait
ruby-2.6.3 - #post-configuration - please wait
ruby-2.6.3 - #compiling - please wait
ruby-2.6.3 - #installing - please wait
ruby-2.6.3 - #making binaries executable - please wait
ruby-2.6.3 - #downloading rubygems-3.0.8
ruby-2.6.3 - #extracting rubygems-3.0.8 - please wait
ruby-2.6.3 - #removing old rubygems - please wait
ruby-2.6.3 - #installing rubygems-3.0.8 - please wait
ruby-2.6.3 - #gemset created /Users/mengshun/.rvm/gems/ruby-2.6.3@global
ruby-2.6.3 - #importing gemset /Users/mengshun/.rvm/gemsets/global.gems - please wait
ruby-2.6.3 - #generating global wrappers - please wait
ruby-2.6.3 - #gemset created /Users/mengshun/.rvm/gems/ruby-2.6.3
ruby-2.6.3 - #importing gemsetfile /Users/mengshun/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.3 - #generating default wrappers - please wait
ruby-2.6.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.3 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri

➜ Ruby: ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]

➜ Ruby: rvm use ruby-2.6.3
Using /Users/mengshun/.rvm/gems/ruby-2.6.3

➜ Ruby: rvm --default use 2.6.3
Using /Users/mengshun/.rvm/gems/ruby-2.6.3

  1. 大功告成 然后直接执行pod安装命令

➜ Ruby: sudo gem install -n /usr/local/bin cocoapods
Password:
Fetching concurrent-ruby-1.1.6.gem
Fetching thread_safe-0.3.6.gem
Fetching activesupport-4.2.11.1.gem
Fetching nap-1.1.0.gem
Fetching tzinfo-1.2.6.gem
Fetching i18n-0.9.5.gem
Fetching fuzzy_match-2.0.4.gem
Fetching httpclient-2.8.3.gem
Fetching ffi-1.12.2.gem
Fetching algoliasearch-1.27.1.gem
Fetching ethon-0.12.0.gem
Fetching typhoeus-1.3.1.gem
Fetching netrc-0.11.0.gem
Fetching cocoapods-core-1.9.1.gem
Fetching claide-1.0.3.gem
Fetching cocoapods-deintegrate-1.0.4.gem
Fetching cocoapods-downloader-1.3.0.gem
Fetching cocoapods-plugins-1.0.0.gem
Fetching cocoapods-search-1.0.0.gem
Fetching cocoapods-stats-1.1.0.gem
Fetching cocoapods-trunk-1.4.1.gem
Fetching cocoapods-try-1.1.0.gem
Fetching molinillo-0.6.6.gem
Fetching atomos-0.1.3.gem
Fetching CFPropertyList-3.0.2.gem
Fetching escape-0.0.4.gem
Fetching gh_inspector-1.1.3.gem
Fetching colored2-3.1.2.gem
Fetching cocoapods-1.9.1.gem
Fetching nanaimo-0.2.6.gem
Fetching xcodeproj-1.15.0.gem
Fetching fourflusher-2.3.1.gem
Fetching ruby-macho-1.4.0.gem
Successfully installed thread_safe-0.3.6
Successfully installed tzinfo-1.2.6
Successfully installed concurrent-ruby-1.1.6
Successfully installed i18n-0.9.5
Successfully installed activesupport-4.2.11.1
Successfully installed nap-1.1.0
Successfully installed fuzzy_match-2.0.4
Successfully installed httpclient-2.8.3
Successfully installed algoliasearch-1.27.1
Building native extensions. This could take a while...
Successfully installed ffi-1.12.2
Successfully installed ethon-0.12.0
Successfully installed typhoeus-1.3.1
Successfully installed netrc-0.11.0
Successfully installed cocoapods-core-1.9.1
Successfully installed claide-1.0.3
Successfully installed cocoapods-deintegrate-1.0.4
Successfully installed cocoapods-downloader-1.3.0
Successfully installed cocoapods-plugins-1.0.0
Successfully installed cocoapods-search-1.0.0
Successfully installed cocoapods-stats-1.1.0
Successfully installed cocoapods-trunk-1.4.1
Successfully installed cocoapods-try-1.1.0
Successfully installed molinillo-0.6.6
Successfully installed atomos-0.1.3
Successfully installed CFPropertyList-3.0.2
Successfully installed colored2-3.1.2
Successfully installed nanaimo-0.2.6
Successfully installed xcodeproj-1.15.0
Successfully installed escape-0.0.4
Successfully installed fourflusher-2.3.1
Successfully installed gh_inspector-1.1.3
Successfully installed ruby-macho-1.4.0
Successfully installed cocoapods-1.9.1
Parsing documentation for thread_safe-0.3.6
Installing ri documentation for thread_safe-0.3.6
Parsing documentation for tzinfo-1.2.6
Installing ri documentation for tzinfo-1.2.6
Parsing documentation for concurrent-ruby-1.1.6
Installing ri documentation for concurrent-ruby-1.1.6
Parsing documentation for i18n-0.9.5
Installing ri documentation for i18n-0.9.5
Parsing documentation for activesupport-4.2.11.1
Installing ri documentation for activesupport-4.2.11.1
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for httpclient-2.8.3
Installing ri documentation for httpclient-2.8.3
Parsing documentation for algoliasearch-1.27.1
Installing ri documentation for algoliasearch-1.27.1
Parsing documentation for ffi-1.12.2
Installing ri documentation for ffi-1.12.2
Parsing documentation for ethon-0.12.0
Installing ri documentation for ethon-0.12.0
Parsing documentation for typhoeus-1.3.1
Installing ri documentation for typhoeus-1.3.1
Parsing documentation for netrc-0.11.0
Installing ri documentation for netrc-0.11.0
Parsing documentation for cocoapods-core-1.9.1
Installing ri documentation for cocoapods-core-1.9.1
Parsing documentation for claide-1.0.3
Installing ri documentation for claide-1.0.3
Parsing documentation for cocoapods-deintegrate-1.0.4
Installing ri documentation for cocoapods-deintegrate-1.0.4
Parsing documentation for cocoapods-downloader-1.3.0
Installing ri documentation for cocoapods-downloader-1.3.0
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-search-1.0.0
Installing ri documentation for cocoapods-search-1.0.0
Parsing documentation for cocoapods-stats-1.1.0
Installing ri documentation for cocoapods-stats-1.1.0
Parsing documentation for cocoapods-trunk-1.4.1
Installing ri documentation for cocoapods-trunk-1.4.1
Parsing documentation for cocoapods-try-1.1.0
Installing ri documentation for cocoapods-try-1.1.0
Parsing documentation for molinillo-0.6.6
Installing ri documentation for molinillo-0.6.6
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for CFPropertyList-3.0.2
Installing ri documentation for CFPropertyList-3.0.2
Parsing documentation for colored2-3.1.2
Installing ri documentation for colored2-3.1.2
Parsing documentation for nanaimo-0.2.6
Installing ri documentation for nanaimo-0.2.6
Parsing documentation for xcodeproj-1.15.0
Installing ri documentation for xcodeproj-1.15.0
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for fourflusher-2.3.1
Installing ri documentation for fourflusher-2.3.1
Parsing documentation for gh_inspector-1.1.3
Installing ri documentation for gh_inspector-1.1.3
Parsing documentation for ruby-macho-1.4.0
Installing ri documentation for ruby-macho-1.4.0
Parsing documentation for cocoapods-1.9.1
Installing ri documentation for cocoapods-1.9.1
Done installing documentation for thread_safe, tzinfo, concurrent-ruby, i18n, activesupport, nap, fuzzy_match, httpclient, algoliasearch, ffi, ethon, typhoeus, netrc, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 145 seconds
33 gems installed

➜ Ruby: pod --version
1.9.1
升级成功!
————————————————
版权声明:本文为CSDN博主「顺在路上」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/a892445213/article/details/104837529

你可能感兴趣的:(升级 pod 遇到问题的解决办法)