使用sudo进行宝石安装cocoapods [英] Use sudo for gem install cocoapods
问题描述
当我运行
$ gem install cocoapods
我得到
提取:i18n-0.7.0.gem(100 %)
错误:执行gem时(Gem :: FilePermissionError)
您没有对/Library/Ruby/Gems/2.0.0目录的写入权限。
我读过这篇文章 cocoaPods pod install Permission denied
但没有说明是否正确运行 sudo
在你的 gem install
中(尽管在问题中被问到 - 例如,sudo是否安装了cocoaPods是错误的方式还是正常的方式?)。 $ b
看来你并没有使用任何包管理器。因为您没有对此目录的写入权限,所以 gem install
使用 sudo
没有任何问题。不过,我更喜欢改变该目录的所有权,这样我就不必每次都使用 sudo
。
ie sudo chown -R [登录名] /Library/Ruby/Gems/2.0.0
并确保我拥有写入权限。 sudo chmod -R u + w /Library/Ruby/Gems/2.0.0
考虑使用 rvm
(ruby版本管理器)或 rbenv
When I run
$ gem install cocoapods
I get
Fetching: i18n-0.7.0.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
I've read this post cocoaPods pod install Permission denied
but the answer there doesn't say whether it is correct to run sudo
on your gem install
(despite being asked in the Question - i.e. Is sudo installation of cocoaPods the wrong way or normal way? ).
It seems you are not using any package manager. Since, you don't have write permission to this directory, there is nothing wrong in using sudo
for gem install
.
However, I prefer changing ownership of that directory, so that I don't have to use sudo
every time.
i.e. sudo chown -R [login name] /Library/Ruby/Gems/2.0.0
and ensure that I have write permission. sudo chmod -R u+w /Library/Ruby/Gems/2.0.0
Consider using rvm
(ruby version manager) or rbenv
这篇关于使用sudo进行宝石安装cocoapods的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!