Cocopods 遇到You don't have write permissions for the /usr/bin directory.

安装cocoapods时候

命令 sudo gem install cocopods

提示

tiantaodeMacBook-Pro:~ tiantao$ sudo gem install cocoapods

ERROR: While executing gem ... (Gem::FilePermissionError)

You don't have write permissions for the /usr/bin directory.

解决方案 有人说 前面加sudo 明明已经加了 是无写入到/usr/bin directory 权限

执行此命令即可

sudo gem install cocoapods -n /usr/local/bin

问题二 如果遇到ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /Users/XXX/.gemrc
再操作命令行前面加上 sudo以此来获取权限
比如 删除淘宝镜像gem sources --remove https://ruby.taobao.org/
调整为 sudo gem sources --remove https://ruby.taobao.org/

推荐阅读更多精彩内容