一、安装前准备:
- 查看源
gem sources -l
结果如下:
harsonsdeiMac:~ harsons$ gem sources -l
*** CURRENT SOURCES ***
https://rubygems.org/
2.如果源是https://rubygems.org/,就移除源
gem sources --remove https://rubygems.org/
3.添加新源
gem sources -a https://ruby.taobao.org/
发现报错:
harsonsdeiMac:~ harsons$ gem sources -a https://ruby.taobao.org/
Error fetching https://ruby.taobao.org/:
hostname "ruby.taobao.org" does not match the server certificate (https://ruby.taobao.org/specs.4.8.gz)
查了一下,发现原来是taobao Gems 源已停止维护,现由 ruby-china 提供镜像服务。
3-1.添加新源
gem sources -a https://gems.ruby-china.org/
结果如下:
harsonsdeiMac:~ harsons$ gem sources -a https://gems.ruby-china.org/
Error fetching https://gems.ruby-china.org/:
bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
3-2.在网上找到正确的添加方式:
gem sources --add https://gems.ruby-china.com
添加成功!
可以再用gem sources -l命令查看,新的源是否添加成功。
harsonsdeiMac:~ harsons$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com
二、安装cocoa pods
直接执行命令:
sudo gem install cocoapods
然后输入电脑密码,就安装成功了。
网友评论