在公司用最新的cocoapods编辑一个项目,回家用自己无法修改podfile文件,报错原因在于cocoapods版本不对,但执行sudo gem update,却提示升级失败。
打开https://ruby.taobao.org/,提示“我们已经停止基于 HTTP 协议的镜像服务, 请在配置中使用 HTTPS 协议代替”,一查本地的资源地址(gem sources )果然是基于http协议。
按官网提示方法:
gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
之后再执行 还是打印下面错误
Updating rubygems-update
ERROR: While executing gem ... (OpenSSL::SSL::SSLError)
SSL_connect returned=1 errno=0 state=SSLv3 read server hello A: wrong version number
直觉告诉我这个地址有问题,
再执行一次
gem sources --add https://ruby.taobao.org
查看当前资源地址(gem sources)
*** CURRENT SOURCES ***
https://ruby.taobao.org/
https://ruby.taobao.org
看出区别了吗 删除上面那个 gem sources --remove https://ruby.taobao.org/
再此更新
$ sudo gem update
Updating installed gems
Updating activesupport
Fetching: activesupport-4.2.5.gem (100%)
Successfully installed activesupport-4.2.5
Parsing documentation for activesupport-4.2.5
Installing ri documentation for activesupport-4.2.5
完美解决。
接着更新cocoapods (更新和安装无区别)
localhost:~ mac$ sudo gem install cocoapods
Password:
Successfully installed cocoapods-0.39.0
Parsing documentation for cocoapods-0.39.0
Done installing documentation for cocoapods after 3 seconds
1 gem installed
localhost:~ mac$ pod setup
/Users/mac/.rvm/gems/ruby-2.2.2@global/gems/cocoapods-0.39.0/lib/cocoapods/command.rb:129: warning: Insecure world writable dir /Users/mac/Desktop/apache/apache-tomcat-6.0.43/bin in PATH, mode 040777
Setting up CocoaPods master repo
Setup completed
总结:正确的资源地址 https://ruby.taobao.org 官网错误的在后面加了“/”。