新电脑,安装cocoapods的时候报错,报错截图如下:
安装失败好久了,一直不是必须要安装pod,所以没有在意没去解决,今天实在要安装pod复现个问题,终于动手搜了下这个报错,试了下这个博客的解决方式,搞定。
报错原因猜测是ruby的版本和最新的pod版本兼容性有问题, 所以必须先升级ruby。
解决步骤:
-
安装 rvm
curl -L https://get.rvm.io | bash -s stable
安装成功会出现下图提示:
如果失败, 出现了这样的错误(报错内容 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation timed out),需要执行下列指令:
sudo gem install redis
然后继续执行rvm的安装命令:
curl -L https://get.rvm.io | bash -s stable
如果还是报 443 错误, 那就等一会再执行, 多次重试总会成功的。 安装 ruby 2.6
rvm install ruby-2.6
运行后:
✘ ryhnsong@RyhndeMacBook-Pro ~ rvm install ruby-2.6
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/11.5/x86_64/ruby-2.6.6.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Updating certificates bundle '/usr/local/etc/openssl@1.1/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/ryhnsong/.rvm/rubies/ruby-2.6.6, this may take a while depending on your cpu(s)...
ruby-2.6.6 - #downloading ruby-2.6.6, 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.4M 100 13.4M 0 0 11567 0 0:20:22 0:20:22 --:--:-- 16887
ruby-2.6.6 - #extracting ruby-2.6.6 to /Users/ryhnsong/.rvm/src/ruby-2.6.6 - please wait
ruby-2.6.6 - #configuring - please wait
ruby-2.6.6 - #post-configuration - please wait
ruby-2.6.6 - #compiling - please wait
ruby-2.6.6 - #installing - please wait
ruby-2.6.6 - #making binaries executable - please wait
ruby-2.6.6 - #downloading rubygems-3.0.9
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 865k 100 865k 0 0 25855 0 0:00:34 0:00:34 --:--:-- 10055
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.6 - #extracting rubygems-3.0.9 - please wait
ruby-2.6.6 - #removing old rubygems - please wait
ruby-2.6.6 - #installing rubygems-3.0.9 - please wait
ruby-2.6.6 - #gemset created /Users/ryhnsong/.rvm/gems/ruby-2.6.6@global
ruby-2.6.6 - #importing gemset /Users/ryhnsong/.rvm/gemsets/global.gems - please wait
ruby-2.6.6 - #generating global wrappers - please wait
ruby-2.6.6 - #gemset created /Users/ryhnsong/.rvm/gems/ruby-2.6.6
ruby-2.6.6 - #importing gemsetfile /Users/ryhnsong/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.6 - #generating default wrappers - please wait
ruby-2.6.6 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.6 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
设置rvm使用版本:
rvm use ruby-2.6.6
设置rvm默认使用版本:
rvm --default use 2.6.6
- 重新安装cocoapods:
sudo gem install cocoapods
安装成功:
Fetching concurrent-ruby-1.1.9.gem
Fetching i18n-1.8.11.gem
Fetching tzinfo-2.0.4.gem
Fetching zeitwerk-2.5.1.gem
Fetching activesupport-6.1.4.1.gem
Fetching fuzzy_match-2.0.4.gem
Fetching nap-1.1.0.gem
Fetching httpclient-2.8.3.gem
Fetching typhoeus-1.4.0.gem
Fetching netrc-0.11.0.gem
Fetching algoliasearch-1.27.5.gem
Fetching ffi-1.15.4.gem
Fetching ethon-0.15.0.gem
Fetching public_suffix-4.0.6.gem
Fetching addressable-2.8.0.gem
Fetching cocoapods-core-1.11.2.gem
Fetching cocoapods-plugins-1.0.0.gem
Fetching claide-1.0.3.gem
Fetching cocoapods-deintegrate-1.0.5.gem
Fetching cocoapods-try-1.2.0.gem
Fetching cocoapods-downloader-1.5.1.gem
Fetching cocoapods-search-1.0.1.gem
Fetching cocoapods-trunk-1.6.0.gem
Fetching molinillo-0.8.0.gem
Fetching atomos-0.1.3.gem
Fetching rexml-3.2.5.gem
Fetching CFPropertyList-3.0.5.gem
Fetching escape-0.0.4.gem
Fetching colored2-3.1.2.gem
Fetching fourflusher-2.3.1.gem
Fetching nanaimo-0.3.0.gem
Fetching gh_inspector-1.1.3.gem
Fetching xcodeproj-1.21.0.gem
Fetching ruby-macho-2.5.1.gem
Fetching cocoapods-1.11.2.gem
Successfully installed concurrent-ruby-1.1.9
Successfully installed i18n-1.8.11
Successfully installed tzinfo-2.0.4
Successfully installed zeitwerk-2.5.1
Successfully installed activesupport-6.1.4.1
Successfully installed nap-1.1.0
Successfully installed fuzzy_match-2.0.4
Successfully installed httpclient-2.8.3
A new major version is available for Algolia! Please now use the https://rubygems.org/gems/algolia gem to get the latest features.
Successfully installed algoliasearch-1.27.5
Building native extensions. This could take a while...
Successfully installed ffi-1.15.4
Successfully installed ethon-0.15.0
Successfully installed typhoeus-1.4.0
Successfully installed netrc-0.11.0
Successfully installed public_suffix-4.0.6
Successfully installed addressable-2.8.0
Successfully installed cocoapods-core-1.11.2
Successfully installed claide-1.0.3
Successfully installed cocoapods-deintegrate-1.0.5
Successfully installed cocoapods-downloader-1.5.1
Successfully installed cocoapods-plugins-1.0.0
Successfully installed cocoapods-search-1.0.1
Successfully installed cocoapods-trunk-1.6.0
Successfully installed cocoapods-try-1.2.0
Successfully installed molinillo-0.8.0
Successfully installed atomos-0.1.3
Successfully installed rexml-3.2.5
Successfully installed CFPropertyList-3.0.5
Successfully installed colored2-3.1.2
Successfully installed nanaimo-0.3.0
Successfully installed xcodeproj-1.21.0
Successfully installed escape-0.0.4
Successfully installed fourflusher-2.3.1
Successfully installed gh_inspector-1.1.3
Successfully installed ruby-macho-2.5.1
Successfully installed cocoapods-1.11.2
Parsing documentation for concurrent-ruby-1.1.9
Installing ri documentation for concurrent-ruby-1.1.9
Parsing documentation for i18n-1.8.11
Installing ri documentation for i18n-1.8.11
Parsing documentation for tzinfo-2.0.4
Installing ri documentation for tzinfo-2.0.4
Parsing documentation for zeitwerk-2.5.1
Installing ri documentation for zeitwerk-2.5.1
Parsing documentation for activesupport-6.1.4.1
Installing ri documentation for activesupport-6.1.4.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.5
Installing ri documentation for algoliasearch-1.27.5
Parsing documentation for ffi-1.15.4
Installing ri documentation for ffi-1.15.4
Parsing documentation for ethon-0.15.0
Installing ri documentation for ethon-0.15.0
Parsing documentation for typhoeus-1.4.0
Installing ri documentation for typhoeus-1.4.0
Parsing documentation for netrc-0.11.0
Installing ri documentation for netrc-0.11.0
Parsing documentation for public_suffix-4.0.6
Installing ri documentation for public_suffix-4.0.6
Parsing documentation for addressable-2.8.0
Installing ri documentation for addressable-2.8.0
Parsing documentation for cocoapods-core-1.11.2
Installing ri documentation for cocoapods-core-1.11.2
Parsing documentation for claide-1.0.3
Installing ri documentation for claide-1.0.3
Parsing documentation for cocoapods-deintegrate-1.0.5
Installing ri documentation for cocoapods-deintegrate-1.0.5
Parsing documentation for cocoapods-downloader-1.5.1
Installing ri documentation for cocoapods-downloader-1.5.1
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-search-1.0.1
Installing ri documentation for cocoapods-search-1.0.1
Parsing documentation for cocoapods-trunk-1.6.0
Installing ri documentation for cocoapods-trunk-1.6.0
Parsing documentation for cocoapods-try-1.2.0
Installing ri documentation for cocoapods-try-1.2.0
Parsing documentation for molinillo-0.8.0
Installing ri documentation for molinillo-0.8.0
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for rexml-3.2.5
Installing ri documentation for rexml-3.2.5
Parsing documentation for CFPropertyList-3.0.5
Installing ri documentation for CFPropertyList-3.0.5
Parsing documentation for colored2-3.1.2
Installing ri documentation for colored2-3.1.2
Parsing documentation for nanaimo-0.3.0
Installing ri documentation for nanaimo-0.3.0
Parsing documentation for xcodeproj-1.21.0
Installing ri documentation for xcodeproj-1.21.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-2.5.1
Installing ri documentation for ruby-macho-2.5.1
Parsing documentation for cocoapods-1.11.2
Installing ri documentation for cocoapods-1.11.2
Done installing documentation for concurrent-ruby, i18n, tzinfo, zeitwerk, activesupport, nap, fuzzy_match, httpclient, algoliasearch, ffi, ethon, typhoeus, netrc, public_suffix, addressable, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-trunk, cocoapods-try, molinillo, atomos, rexml, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 36 seconds
35 gems installed
备注:解决方案完全参考这个博客,感谢这位博主的分享!