MacOS 10.12 pod update時遇到的問題:unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead() return

3.16 解決辦法
使用SSH

配置github SSH

git config --global user.email "zhenghan1221@163.com"

創(chuàng)建公鑰密鑰,保存路徑默認(rèn),直接按Enter鍵,輸入密碼同樣Enter鍵
ssh-keygen -t rsa -C "zhenghan1221@163.com"

屏幕快照 2017-03-16 20.26.55.png

前往文件夾 /用戶/qiyong/.ssh,找到id_rsa.pub文件,使用文本編輯打開后,全選復(fù)制,然后登陸GitHub賬戶,在設(shè)置中找到SSH和GPG密鑰,選擇New SSH Key新建密鑰,將復(fù)制的內(nèi)容粘貼進去,Add創(chuàng)建成功。

在終端中下載

cd ~/.cocoapods/repos git clone git@github.com:Cocoapods/Specs.git master

然后執(zhí)行命令
rm ~/Library/Caches/CocoaPods/search_index.json
再pod search 就可以了。

pod 更新和安裝采用以下命令
pod install --verbose --no-repo-update pod update --verbose --no-repo-update

轉(zhuǎn)為SSH,其實和直接使用http,或者下載好資源再拷貝到~/.cocoapods/repos目錄下的解決辦法,并沒有什么區(qū)別。

注意:可使用命令查看當(dāng)前的請求方式
git remote -v

屏幕快照 2017-03-16 20.35.27.png

3.8號的時候,好多app 因使用熱修復(fù)而收到警告,盡管我還沒有收到郵件警告,但這個問題既然那么多人遇到了,咱還是及時把Hotfix清除掉吧,于是由此引發(fā)了一系列問題。在此以作記錄,方便以后查閱。3.15仍無法解決SSL證書問題,于是以http替代https
qimatoMacBook-Pro:~ qiyong$ gem sources -l *** CURRENT SOURCES ***https://gems.ruby-china.org qimatoMacBook-Pro:~ qiyong$ gem sources --add http://gems.ruby-china.org/ --remove https://gems.ruby-china.org http://gems.ruby-china.org/ added to sourceshttps://gems.ruby-china.org removed from sources qimatoMacBook-Pro:~ qiyong$ gem sources -l *** CURRENT SOURCES *** http://gems.ruby-china.org/ qimatoMacBook-Pro:~ qiyong$ sudo gem install -n /usr/local/bin cocoapods qimatoMacBook-Pro:~ qiyong$ pod setup

3.15 以下嘗試均失敗!首先是pod update 失敗,于是我就去更新pod ,然后在pod setup時遭遇一下錯誤:

fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': Server aborted the SSL handshake[!] CocoaPods was not able to update the master repo. If this is an unexpected issue and persists you can inspect it running pod repo update --verbose

rvm升級

在這一過程中我也走了彎路,沒能準(zhǔn)確的找到問題的根源所在,于是查看了下ruby的最新環(huán)境2.3.0 當(dāng)時我的rvm是1.27的版本,于是我直接去更新ruby,遭遇錯誤:

D857F8A7B7A0166BD058FC464D6ECEB7.jpg

于是,對rvm進行升級,
\curl -sSL https://get.rvm.io | bash -s stable
$curl -L get.rvm.io | bash -s stable
載入rvm 環(huán)境 $source ~/.rvm/scripts/rvm
或者在當(dāng)前的窗口中繼續(xù)輸入$rvm update
然后查看rvm的版本就可知道是否真的安裝成功$rvm -v

使用rvm對ruby進行升級

查看ruby的最新版本$rvm list known
安裝rubyrvm install 2.4.0
設(shè)置默認(rèn)版本,可以用這條命令來完成$ rvm use 2.4.0 --default
查看已安裝的ruby$ rvm list
卸載一個已安裝ruby版本$ rvm remove 2.4.0
在這一過程中,rvm install 2.4.0時遇到上面圖片所展示的問題二,這時我再次查看,注意到了這樣的描述:

Error: /opt/local/bin/port: Failed to initialize MacPorts, OS platform mismatch

問題來了:macPorts的問題如何解決?

打開鏈接:https://www.macports.org/install.php ,選擇當(dāng)前系統(tǒng)對應(yīng)的macports即可,下載完成后點擊安裝。

之后再打開終端新窗口,執(zhí)行ruby的升級命令即可。ruby升級之后,我再次對pod升級,問題依舊:

fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead() return error -9806[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progressCloning into 'master'...fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': SSLRead() return error -9806

這個時候我才意識到問題的根本所在,原來是SSLread的錯誤

查閱資料說是SecureTransport后端使用的curl。
資料中使用到了以下命令:
$ brew remove git $ brew remove curl $ brew install openssl $ brew install --with-openssl curl $ brew install --with-brewed-curl --with-brewed-openssl git

我在終端中輸入了一下brew list,告訴我該命令不可用,原來我的電腦并沒有安裝Homebrew

Homebrew安裝

命令如下
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

在這一過程中遇到如下問題描述:


8A32A3FE-6155-40FF-ACE3-978717D7E36A.png

于是我將github的HTTPS轉(zhuǎn)為SSH
在Terminal中輸入以下命令即可$git remote set-url origin git@github.com:USERNAME/OTHERREPOSITORY.git
完成之后打開新窗口再次安裝brew,
這次成功了,之后就是執(zhí)行brew install openssl
完成后繼續(xù)執(zhí)行brew install --with-openssl curl
最后再次執(zhí)行命令brew install --with-brewed-curl --with-brewed-openssl git
至此,打開新窗口,再次pod setup就成功了。

個人猜測,不知道是否將github的HTTPS轉(zhuǎn)為SSH,即可pod setup成功,當(dāng)時沒有想到這點去嘗試一下。
rvm pkg install openssl2.rvm install 2.3.0 --with-openssl-dir=/Users/milai/.rvm/usr (加粗的代表 第一步安裝openssl的文件目錄)
3.14全部卸載,從頭開始,使用brew安裝了openssl后,繼續(xù)使用brew安裝ruby ,依然失敗 此時系統(tǒng)中的ruby 仍為2.0.0,我想應(yīng)該是缺失了將brew安裝的ruby拷貝到系統(tǒng)中去。

此方式失敗。

而后重裝rvm 安裝ruby采用的以下方式:


屏幕快照 2017-03-14 19.42.10.png

屏幕快照 2017-03-14 19.42.25.png

屏幕快照 2017-03-14 19.42.46.png

此方式仍舊失敗。
官網(wǎng)中說參考這個鏈接中
https://github.com/huacnlee/init.d/blob/master/install_rvm
的方式 正確安裝gem/ruby,但我不知道究竟是哪一步出錯。

看過了這篇文章
http://www.lxweimin.com/p/b64b4fd08d3c
很多人說他們的問題解決了,但我一開始就是正確的安裝姿勢,16年,包括17年2月份更新時都是可以的,沒問題的,3月10號時再次更新,就出錯了。SSL問題到現(xiàn)在也沒找到正確的解鎖姿勢。

另有解決辦法,起初有嘗試過,亦然失敗。
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
這是兩篇關(guān)于解決ruby的openSSL問題的文章:
https://ruby-china.org/topics/28575
http://www.lxweimin.com/p/dc0b99226b83

嘗試過,在make這一步出現(xiàn)問題。
解壓:tar -xzvf ruby-2.4.0.tar.gz

參考鏈接:
1.ruby更新: http://charsdavy.github.io/2016/09/03/mac-ruby-update/
2.輕松幾步搞定CocoaPods修復(fù)10.11不能安裝問題http://www.lxweimin.com/p/9fd6d9ddf4ca3.Mac
3.升級到10.11 出現(xiàn)的問題和解決方法
http://www.lxweimin.com/p/02b74ad2787c
4.http://stackoverflow.com/questions/39434447/unable-to-setup-pods-error-rpc-failed-curl-56-sslread-return-error-9806
5.在SSH和HTTPS之間切換https://help.github.com/articles/changing-a-remote-s-url/
6.http://blog.sina.com.cn/s/blog_bb5a48430102w9j3.html
7.Homebrew安裝 https://brew.sh/index_zh-cn.html
8.http://www.lxweimin.com/p/dc0b99226b83
9.CocoaPods 的簡單快速安裝方法

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容