我试图使用gem install mygem或使用gem update——system更新RubyGems安装一个gem,它失败了,错误如下:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
有人知道怎么解决这个问题吗?
我试图使用gem install mygem或使用gem update——system更新RubyGems安装一个gem,它失败了,错误如下:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
有人知道怎么解决这个问题吗?
当前回答
这对我很管用。另外,如果你之前以根用户的身份安装了gems,它会通过将所有权交还给你来解决这个问题(更安全)。
sudo chown -R `whoami` /Library/Ruby/Gems
其他回答
你可以使用:gem install cocoapods——pre——user
为我工作:
sudo gem uninstall cocoapods
sudo gem install cocoapods
该错误的原因是您没有以root用户登录终端。
如果你已经在终端类型的mac上启用了根用户
$ su
如果您没有root用户,您需要使用以下步骤启用它
From the Apple menu choose System Preferences…. From the View menu choose Users & Groups. Click the lock and authenticate as an administrator account. Click Login Options…. Click the “Edit…” or “Join…” button at the bottom right. Click the “Open Directory Utility…” button. Click the lock in the Directory Utility window. Enter an administrator account name and password, then click OK. Choose Enable Root User from the Edit menu. Enter the root password you wish to use in both the Password and Verify fields, then click OK.
更多内容请登录http://support.apple.com/kb/ht1528
在被困了几个小时后,至少它对我有用。
sudo gem update --system
sudo gem install (gemfile)
有两种路由:使用rbenv或RVM。下面是这两种食物的食谱。在此之前,您可能希望关闭gem本地文档的安装。
echo "gem: --no-ri --no-rdoc" >> ~/.gemrc
然后:
安装rbenv
安装ruby-build
运行:
rbenv install 2.1.2 (or whatever version you prefer)
rbenv global 2.1.2
gem update --system
这将在本地目录中安装gem系统的最新版本。这意味着您不会干扰系统配置。如果您正在问这个问题,那么您不应该破坏系统安全性,并且您将花费更长的时间来了解可能遇到的问题,而不仅仅是找到一种简单的方法来避免您开始时遇到的问题。了解更多关于操作系统和编程的知识后,再学习InfoSec。
使用'RVM'替代:
rvm install 2.1.2
rvm use 2.1.2
gem update --system
这有同样的结果,您最终得到的是一个本地Ruby和Gem系统,它不会影响系统版本。不需要Homebrew,也不需要覆盖系统库等等。