MAC机 配置RVM环境之链接失败-curl:(7)& curl:(35)
问题背景
在配置cocoapods时,遇到需要配置RVM环境的问题
最近给新电脑配置cocoapods,依旧follow许公子的步骤Cocoapods安装方法
只是在第二步的操作时,curl -L get.rvm.io | bash -s stable
一直443,我真的是重试N遍不成功.
首先报error:
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
如果你想直接看我的有效办法,绕过探索路径,可直接看终极探索
探索1
我 follow 该问这位道友的方法一
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused的几种解决方式
开始报error:
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443。
尝试方法二,依旧 error 443.
(当然,方案三和四,都是关于HomeBrew的,就没在借鉴)
探索2
然后,我继续寻找我的解决办法,看到这位道友的文章,激动了一下.
在Mac下安装brew报错curl: (7)
一尝试,的确是网页打不开(悲伤辣么大!!!)
而我并没有小梯子,只要继续寻找其他出路。。。
探索3
从这位道友这里得到灵感,既然“离服务器太远”,那就看看有没有国内RVM源.
mac安装brew错误解决:curl: (7) Failed to connect to raw.githubusercontent.com
更换搜索“安装rvm失败,国内源”
结论是:需要在先下载rvm之后,再更换源
能搜索的文章,都被重复搜索了 more than 3 times了. 我依旧被connection refussed ,我的 cocoapods还没能装上…
不要放弃,寻找生机,硬性执行安装cocoapods的结果会怎样(报侥幸心理,万一这次好了呢)?
apple-MacBook-Pro:~ Bear$ sudo gem install -n /usr/local/bin cocoapods
Password:
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210622-9294-1igfurf.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
侥幸终归是侥幸,在搜索Error installing cocoapods 之后,又回到了最初的起点,是因为ruby版本过低,需要升级ruby
当然也有其他说法,比如Cocoapods升级报错Error installing cocoapods: Failed to build gem native extension
各位道友自行google.
终极探索
既然国外源 connection refused,国内源需要先Download (也就是执行 curl -L get.rvm.io | bash -s stable),于是想到了是否可以离线安装rvm,只要拿到rvm的包就好
于是搜到了
离线安装rvm
简单总结一下,共3步:
Step1: 终端输入 git clone https://github.com/rvm/rvm.git
,从github 下载
Step2: 下载完成,双击打开 users/your home disk's name /rvm/bin/rvm-installer
(一定要替换为你的磁盘名)
Step3: 让rvm 命令生效 source ~/.rvm/scripts/rvm
(可选操作)
终极探索,到此结束。
apple-MacBook-Pro:~ Bear$ rvm -v
rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
终于有rvm环境,可以follow开篇 -安装cocoapods的文档,升级ruby,安装cocoapods啦~~~
apple-MacBook-Pro:~ Bear$ ruby -v
ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-darwin19] // ruby是升级之后的版本
当然,pod的安装下载,依然依靠网络的好坏,即使国内的源
补充:
- 关于homebrew的安装,如果同样出现-curl:(7), 可以参考https://zhuanlan.zhihu.com/p/90508170
找到国内的源,下载homebrew快一些。
这句即可
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
截图补充(原道友若不喜欢,留言我删除哈,猫猫能有什么坏心思呢,就是担心知乎网页打不开而已啦 @_<)
温馨提示:
- 想了解rvm的道友,可以参考下该文档 RVM Ruby 管理工具
- 有道友说rvm不是必需的,你可以先尝试直接装pods,是否能成功。如果不成功,依然需要 安装rvm
- 借鉴的文章归原作者所有。这里是记录我的探索之路,当然各位道友的文章对我带来很多思考呢~