今天安装cocoapods,遇到了需要ruby版本2.2.2以上的问题,我就升级我的ruby,使用rvm升级遇到了各种问题,最终也是没有解决,于是就使用手动升级。
首先下载ruby-2.3(链接:https://cache.ruby-china.org/pub/ruby/),下载好了后解压到桌面。
打开终端,一次输出以下命令进行安装
$ cd ruby-2.3.0
$ ./configure --with-openssl-dir=/usr/local/ssl
$ make
$ sudo make install
执行完后,安装cocoapods,在替换源的时候就出现了下面的问题:
RROR: While executing gem ... (Gem::Exception) Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources!
我一个小白真是一脸懵逼啊,没事,继续百度。
百度说:
mac升级10.11后,关于openssl的问题出现了很多。 按下面方法编译前,需要确认由openssl目录。今天我在一台全新mac上安装,发现只有openssl可执行文件而没有对应目录。 可到openssl.org下载安装后执行以下方法,即可解决。
前两天在osx 10.11上编译安装了ruby2.3.0。 然后安装gem时, 会有错误提示: ERROR: While executing gem ... (Gem::Exception) Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
重新编译发现, make的输出中有 configuring openssl Failed to configure openssl. It will not be installed. 如上字样。
解决方法:
1, 去ruby官网下载ruby-2.3.3
2,安装openssl ,一般用brew install openssl 安装后路径为/usr/local/Cellar/openssl/1.0.2j
3,安装ruby:解压ruby-2.3.3后(我解压之后直接放到桌面的), 进入其目录,执行:
$ ./configure --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2j
$ make
$ sudo make install
等待安装完成,然后进行我们的cocoapods 安装,
输入以下命令查看我们的源。
$ gem source -l
通过以下命令更换源(因为源被我们给墙了):
$ gem source -r https://rubygems.org/
$gem source -a https://gems.ruby-china.org/
下面就是见证奇迹的时候了,安装cocoapods
$ sudo gem install cocoapods
等待一段时间
输入,查看是否安装成功
$ pod --version
显示 1.1.1,证明安装成功了,至此,终于完成了。坑太多了。
网友评论