最近因?yàn)閜od search 無法查詢到最新第三方庫,需要更有cocoapods。記錄過程遇到的問題。
1. 首先安裝 pod執(zhí)行sudo gem installcocoapods。
報錯
ERROR:Error installing cocoapods:
activesupport requires Ruby version >= 2.2.2.
提示Ruby版本過低,需要升級Ruby
2.升級Ruby
2.1 查看Ruby版本?
ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15] 確實(shí)版本過低。
2.2 升級Ruby 需要安裝rvm
如果已經(jīng)安裝可以忽略。
沒有安裝需要執(zhí)行以下命令
curl -L get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
檢測是否安裝成功 rvm -v
輸出 rvm 1.29.3 (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io].即可
2.3 查看可以安裝ruby版本 rvm list known
輸出
# MRI Rubies[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10][ruby-]2.2[.8]
[ruby-]2.3[.5]
[ruby-]2.4[.2]
[ruby-]2.5[.0-preview1]ruby-head# for forks use: rvm install ruby-head---url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.27]
jruby[-9.1.13.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx-3[.86]
rbx-head
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
mruby-1[.3.0]
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
# Topaz
topaz
# MagLev
maglev[-head]
maglev-1.0.0
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
# IronRuby
ironruby[-1.1.3]
ironruby-head
2.4 安裝最新的是rvm install ruby-head---url
報錯404 可能和網(wǎng)絡(luò)相關(guān)無奈只好嘗試其他版本。
rvm install 2.4.2
報錯
'Failed to update Homebrew, follow instructions here
XXXX
Requirements installation failed with status: 1.
提示 需要升級brew。
3.升級brew
執(zhí)行 brew update
報錯基本是一些權(quán)限問題,修改文件權(quán)限即可。
執(zhí)行成功查看版本brew --version
Homebrew 1.3.5
Homebrew/homebrew-core (git revision a75a9; last commit 2017-10-16)
4.重新安裝Ruby
rvm install 2.4.2
4.1報錯:error: RPC failed; curl 56 SSLRead() return error -36
一般原因是因?yàn)檠b了多個Xcode造成的
卸載,安裝最新xcode即可或者執(zhí)行
sudo xcode-select-switch/Applications/Xcode.app/Contents/Developer也可。
再次執(zhí)行rvm install 2.4.2
4.2報錯:Library not loaded: /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (LoadError)
卸載 ruby ? rvm uninstall 2.4.2
重新安裝 rvm reinstall 2.4.2 (很重要)。
4.3再次報錯
*** Following extensions failed to configure:
../.././ext/gdbm/extconf.rb:0: Failed to configure gdbm. It will not be installed.
*** Fix the problems, then remove these directories and try again if you want.
make[2]: `ruby' is up to date.
making enc
make[1]: Nothing to be done for `enc'.
making trans
make[1]: Nothing to be done for `./enc/trans'.
making encs
make[1]: Nothing to be done for `encs'.
./miniruby -I./lib -I. -I.ext/common? ./tool/runruby.rb --extout=.ext? -- --disable-gems -r./x86_64-darwin16-fake ./tool/rbinstall.rb --make="/Applications/Xcode.app/Contents/Developer/usr/bin/make" --dest-dir="" --extout=".ext" --mflags="" --make-flags="" --data-mode=0644 --prog-mode=0755 --installed-list .installed.list --mantype="doc"
installing binary commands:? /Users/jeff/.rvm/rubies/ruby-2.4.2/bin
dyld: lazy symbol binding failed: Symbol not found: _utimensat
Referenced from: /Users/jeff/.rvm/src/ruby-2.4.2/libruby.2.4.2.dylib
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _utimensat
Referenced from: /Users/jeff/.rvm/src/ruby-2.4.2/libruby.2.4.2.dylib
Expected in: /usr/lib/libSystem.B.dylib
make: *** [do-install-nodoc] Abort trap: 6
++ return 2
卸載重新安裝試了多次無效。最后嘗試是XCode不是最新原因
可以安裝最新Xcode如果還是不行,可以執(zhí)行以下命令
brew install rbenv ruby-build
sudo xcode-select --install
4.4 重新安裝 rvm reinstall 2.4.2 終于成功。
查看版本 ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
5 最后安裝pod即可 執(zhí)行
sudo gem install cocoapods
5.1 gem source -r https://ruby.taobao.org/ (淘寶資源不能用)
增加新的資源地址
gem source -a https://gems.ruby-china.org/
pod setup 等待即可