1、ruby环境
在安装Cocoapod前要确认ruby是否正确安装,可以用如下命令确认当前ruby环境:
bogon:~ wangpo$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
bogon:~ wangpo$ gem -v
2.7.6
2、gem源
- 查看gem源
bogon:~ wangpo$ gem sources -l
CURRENT SOURCES
- 移除系统自带的源
bogon:~ wangpo$ gem sources –remove https://rubygems.org/
https://rubygems.org/ removed from sources
bogon:~ wangpo$ gem sources -l
CURRENT SOURCES - 添加新源
bogon:~ wangpo$ sudo gem sources –add https://gems.ruby-china.org/
Password:
https://gems.ruby-china.org/ added to sources
bogon:~ wangpo$ gem sources -l
CURRENT SOURCES
3、安装Cocoapod
- 没有权限安装
bogon:~ wangpo$ gem install cocoapods
Fetching: concurrent-ruby-1.0.5.gem (100%)
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
No permissions for the /usr/bin directory.
bogon:~ wangpo$ sudo gem install cocoapods
…
…
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /usr/bin directory.
- 正确打开方式
bogon:~ wangpo$ sudo gem install cocoapods -n /usr/local/bin
Successfully installed fuzzy_match-2.0.4
Fetching: cocoapods-core-1.4.0.gem (100%)
…
…
22 gems installed
安装成功
bogon:~ wangpo$ pod –version
1.4.0
近期评论