标签:
在mac上安装cocoapods,一路的坑啊,无数报错啊有木有!
本以为安装很简单,mac下都自带ruby,使用ruby的gem命令即可下载安装:
$ sudo gem install cocoapods
$ pod setup
报错!有可能是gem版本太老,升级一下gem:
$ sudo gem update --system
完成后重新执行开始那两行,又报错:
Error installing pods:activesupport requires Ruby version >= 2.2.2
ruby版本太低,查看当前mac的ruby版本
$ ruby -v
输出ruby 1.8.7,现在需要使用RVM对Ruby进行升级,RVM是Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gemset),现在我们先安装RVM:
$ curl -L get.rvm.io | bash -s stable
等一会儿安装成功RVM后:
$ source ~/.bashrc
$ source ~/.bash_profile
查看是否安装正常:
$ rvm -v
完成后,用RVM升级Ruby,可以先列出所有的ruby版本:
$ rvm list known
安装ruby 2.3.0
$ rvm install 2.3.0
安装完成之后查看是否安装成功:
$ ruby -v
完成后重新执行开始那两行,又报错!ruby软件源被墙了,更新一下ruby源,将官方的ruby源替换成国内淘宝的源:
$ gem sources --remove https://rubygems. org/
$ gem sources -a https://ruby.taobao.org/ // 注意是https而不是http
$ gem sources -l
输出:
*** CURRENT SOURCES ***
https://ruby.taobao.org/ // 确保只有一个源
重新执行开始那两行,等了好久好久,期间查看下载进度:
$ cd ~/.cocoapods
$ du -sh *
下载了270M后的某个时候,又报错:
Setting up CocoaPods master repo
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master –depth=1
Cloning into ‘master’…
error: RPC failed; result=18, HTTP code = 200
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
郁闷了,白等了好久,查资料后:
$ git config --global http.postBuffer 524288000
$ git config --list
重新执行:
$ pod setup
等了好久好久后,又报上面那个错,再查资料后:
$ pod repo remove master // 移除master
$ sudo gem uninstall cocoapods // 卸载cocoapods
1、卸载pod
获取pod的路径:
$ which pod
删除pod
$ sudo rm -rf <pod的路径>
2、删除rubygems相关cocoapods的包
查看rubygems的本地程序包
$ gem list
输出:
***LOCALGEMS***
activesupport(4.2.3)
bigdecimal(1.2.0)
CFPropertyList(2.2.8)
claide(1.0.0.beta.1,0.9.1)
cocoapods(0.39.0,0.39.0.beta.4,0.38.2)
cocoapods-core(1.0.0.beta.4,0.39.0,0.39.0.beta.4,0.38.2)
cocoapods-deintegrate(1.0.0.beta.1)
cocoapods-downloader(1.0.0.beta.1,0.9.3,0.9.1)
cocoapods-plugins(1.0.0.beta.1,0.4.2)
cocoapods-search(1.0.0.beta.1,0.1.0)
cocoapods-stats(1.0.0.beta.3,0.6.2,0.6.1,0.5.3)
cocoapods-trunk(1.0.0.beta.2,0.6.4,0.6.1)
cocoapods-try(1.0.0.beta.2,0.5.1,0.4.5)
colored(1.2)
escape(0.0.4)
fourflusher(0.3.0)
fuzzy_match(2.0.4)
i18n(0.7.0)
io-console(0.4.2)
json(1.7.7)
libxml-ruby(2.6.0)
minitest(5.7.0,4.3.2)
molinillo(0.4.4,0.3.1)
nap(1.0.0,0.8.0)
netrc(0.7.8)
nokogiri(1.5.6)
psych(2.0.0)
rake(0.9.6)
rdoc(4.0.0)
rubygems-update(2.4.8)
sqlite3(1.3.7)
test-unit(2.0.0.0)
thread_safe(0.3.5)
tzinfo(1.2.2)
xcodeproj(1.0.0.beta.3,0.28.2,0.27.2,0.26.3)
移除跟cocoapods相关的程序包
cocoapods (0.39.0, 0.39.0.beta.4, 0.38.2)
cocoapods-core (1.0.0.beta.4, 0.39.0, 0.39.0.beta.4, 0.38.2)
cocoapods-deintegrate (1.0.0.beta.1)
cocoapods-downloader (1.0.0.beta.1, 0.9.3, 0.9.1)
cocoapods-plugins (1.0.0.beta.1, 0.4.2)
cocoapods-search (1.0.0.beta.1, 0.1.0)
cocoapods-stats (1.0.0.beta.3, 0.6.2, 0.6.1, 0.5.3)
cocoapods-trunk (1.0.0.beta.2, 0.6.4, 0.6.1)
cocoapods-try (1.0.0.beta.2, 0.5.1, 0.4.5)
把这些文件全部卸载
代码:sudo gem uninstal <文件名>
以删除cocoapods为例
$ sudo gem uninstal cocoapods
输出:sudo gem uninstal cocoapods
3、删除完之后,执行安装cocoapods
$ sudo gem install -n /usr/local/bin cocoapods--pre
安装完之后:
$ pod--version
输出:1.0.1
再次执行
$ pod setup
.
.
.
又是等了好久好久,又是报错:
[!] /usr/local/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into‘master‘...
error: RPC failed; result=56, HTTP code =200
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
我要崩溃啦啦啦啦啦啦啦啦
再次设置
$ git config --global http.postBuffer 524288000 // 1024*1024*500 = 500M
$ pod setup
还是一样的报错如上,有可能是postBuffer还不够大的原因,配置一个超级大的值试试:
$ git config --global http.postBuffer 1073741824 // 1024*1024*1024 = 1024M
$ pod setup
OK,等了好久终于搞定,输出:
Settingup CocoaPods master repo
Setup completed
来,试试CocoaPods是否可以使用,可以用CocoaPods的搜索功能验证一下:
$ pod search AFNetworking
现在终于好了。。。
标签:
原文地址:http://www.cnblogs.com/hankkk/p/5703050.html