Ruby gem 权限被拒绝 /var/lib/gems 使用 Ubuntu
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11496591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ruby gem permission denied /var/lib/gems using Ubuntu
提问by Yannick
I'm trying to install Rails using Gem and did the following from the terminal:
我正在尝试使用 Gem 安装 Rails,并从终端执行以下操作:
sudo apt-get install ruby-full build-essential
sudo apt-get install rubygems
export PATH=/var/lib/gems/1.8/bin:$PATH
gem install rails
Then I get the following message:
然后我收到以下消息:
ERROR: While executing gem ... (Errno:EACCES) Permission denied - /var/lib/gems
错误:执行 gem 时...(错误:EACCES)权限被拒绝 - /var/lib/gems
I've followed the instruction from Ubuntu Help Guide& I'm using Oracle VM VirtualBox to run Ubuntu under Windows 7 and have RubyGems v1.8.15.
我已按照Ubuntu 帮助指南中的说明进行操作,我正在使用 Oracle VM VirtualBox 在 Windows 7 下运行 Ubuntu 并拥有 RubyGems v1.8.15。
回答by Linuxios
You need to prefix the gemcommand with sudobecause /var/lib/gemsis owned by root. You could also take a look at RVMwhich allows reallyeasy installation and management of gems and Ruby versions. Best part, it's all in your home dir!
您需要在gem命令前加上sudo因为/var/lib/gems是由root. 您还可以查看RVM,它允许真正轻松地安装和管理 gems 和 Ruby 版本。最好的部分,这一切都在您的家庭目录中!
EDIT: per @AndrewMarshall's comment bellow, rbenv is an alternative to RVM.
编辑:根据@AndrewMarshall 的评论,rbenv 是 RVM 的替代品。

