更新 cocoapods 的时候,提示 ruby 版本低,下面是升级 ruby 的坎坷之路。
1、使用 sudo gem install cocoapods 更新 cocoapods 报错,需要 ruby version >= 2.6
2、去 ruby 官网下载 ruby-2.6.0,由于 macOS 版本较低,没有下载最新的 ruby
3、安装 ruby,执行以下操作猛如虎,一切正常:
./configure --prefix=/usr/local/ruby-2.6.0
make
sudo make install4、把 ruby 2.6.0 可执行文件导入全局变量 PATH 中,使用如下命令:
echo 'export PATH="/usr/local/ruby-2.6.0/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile至此 ruby 2.6.0 安装成功,使用以下命令查看 ruby 版本:
ruby -v然后终端输出 ruby 版本:
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin17]5、重新执行 sudo gem install cocoapods 又报错,ruby 没有 openssl 模块。
6、重新编译 ruby ,带上 openssl 模块。(就是这一步,浪费了我太多时间)
一开始使用下面的命令
./configure --prefix=/usr/local/ruby-2.6.0 --with-openssl=/usr/bin/opensslmake 后,提示找不到 openssl 库:
*** Following extensions are not compiled:
openssl:
Could not be configured. It will not be installed.
/Users/esdzxc/Downloads/ruby/ruby-2.5.9/ext/openssl/extconf.rb:97: OpenSSL library could not be found. You might want to use --with-openssl-dir= option to specify the prefix where OpenSSL is installed.
Check ext/openssl/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want. 后来发现需要使用 --with-openssl-dir ,所以更改命令再战:
./configure --prefix=/usr/local/ruby-2.6.0 --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2o_1
make
sudo make install7、重新执行 sudo gem install cocoapods ,搞定。
| 留言与评论(共有 0 条评论) “” |