Pod、Ruby环境升级记录
前言
由于团队协同开发,如果每个人的ruby版本或者pod版本不一致时,会导致每个人的Podfile.lock 文件不一致,就需要重新执行 pod install ,重新编译项目,比较麻烦。故将版本进行了一次统一。
在升级的过程中,主要发现了两个问题:
- Gem源地址的域名由 .org 变成了 .com
- 安装ruby遇到请求失败的问题
找了半天,还是在 RubyChina 上找到的靠谱的解决方案
环境
- 时间:2018-10-18
- 系统:macOS 10.14
详细步骤
- 升级Gem(可以跳过)
# 更新Gem版本(这里需要翻墙)
$ gem update --system
# 检查版本
$ gem -v
2.7.7
- 更换Gem源
# 移除旧的源
$ gem sources --remove https://gems.ruby-china.org/
# 添加新的源
$ gem sources -a https://gems.ruby-china.com/
# 查看当前源
$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com
# 确保只有 gems.ruby-china.com
- 安装或升级rvm(已经安装可以跳过)
# 如果未安装rvm
$ curl -sSL https://get.rvm.io | bash -s stable
# 然后,载入 RVM 环境
$ source ~/.rvm/scripts/rvm
# 检查版本
$ rvm -v
rvm 1.29.4 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
# 如果已经安装rvm,想更新
$ rvm get stable
- 安装ruby
# 安装指定版本ruby,这个过程会比较慢
$ rvm install 2.5.1
# 检查版本
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18
如果遇到 SSL 证书问题,你又无法解决,请修改 ~/.gemrc 文件,增加 sslverifymode: 0 配置,以便于 RubyGems 可以忽略 SSL 证书错误。~/.gemrc 内容如下,替换即可。
---
:sources:
- https://gems.ruby-china.com
:ssl_verify_mode: 0
报错具体信息
ETListenerdeMacBook-Pro:biyao ETListener$ rvm install 2.5.1
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.14/x86_64/ruby-2.5.1.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/ETListener/.rvm/rubies/ruby-2.5.1, this may take a while depending on your cpu(s)...
ruby-2.5.1 - #downloading ruby-2.5.1, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (35) error:14004410:SSL routines:CONNECT_CR_SRVR_HELLO:sslv3 alert handshake failure
There was an error(35).
Checking fallback: https://ftp.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2
No fallback URL could be found, try increasing timeout with:
echo "export rvm_max_time_flag=20" >> ~/.rvmrc
There has been an error fetching the ruby interpreter. Halting the installation.
- 安装指定版本pod
# 安装指定版本Pod
$ sudo gem install cocoapods -v 1.5.3
# 检查版本
$ pod --version
1.5.3
相关链接
- RubyChina:https://gems.ruby-china.com/
- Ruby官网:https://www.ruby-lang.org/zh_cn/
- CocoaPods官网:https://cocoapods.org/