Linux RVM gem 权限错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11092690/
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
RVM gem permissions error
提问by Mittenchops
I started trying to set up a local rails installation for development. After I installed in using apt-get
, however, I learned about RVM, so I removed the earlier one, and reinstalled from RVM. It looks like I have residual problems, though. Specifically, when I try to install rails I get...
我开始尝试为开发设置本地 Rails 安装。apt-get
但是,在使用安装后,我了解了 RVM,因此我删除了较早的一个,并从 RVM 重新安装。不过,看起来我有一些遗留问题。具体来说,当我尝试安装导轨时,我得到...
$ gem install rails
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.9.1 directory.
This already looks like a problem, because I don't want it to be in the /var/ directory, I want it to be in the user directory. So, I check the following...
这看起来已经是个问题了,因为我不希望它在 /var/ 目录中,我希望它在用户目录中。所以,我检查以下...
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/myusername/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
As well as sudo'd:
以及sudo'd:
$ sudo gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/myusername/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
gems seem to live in /var/lib for some reason. Is this normal? How can I fix this so I can install the rails gem?
出于某种原因,gems 似乎位于 /var/lib 中。这是正常的吗?我该如何解决这个问题,以便我可以安装 rails gem?
EDIT: UPDATE!
编辑:更新!
It appears to me that I have gems installed twice, once in /var/lib/gems/1.9.91 (bad) and once in /home/myusername/.gem/ruby/1.9.1 (good).
在我看来,我安装了两次 gem,一次在 /var/lib/gems/1.9.91(坏),一次在 /home/myusername/.gem/ruby/1.9.1(好)。
I think what is happening here is that when I type "gem" the installation in /var/lib/gems/1.9.1 (bad) is taking priority over /home/myusername/.gem/ruby/1.9.1 (good). Can anyone confirm that? Also, would it be OK and fix things just to delete the bad directory, or would that cause problems?
我认为这里发生的事情是,当我输入“gem”时,/var/lib/gems/1.9.1(坏)中的安装优先于/home/myusername/.gem/ruby/1.9.1(好) . 任何人都可以确认吗?另外,是否可以仅通过删除错误目录来修复问题,还是会导致问题?
采纳答案by mpapis
You missed to use ruby, you can do it with:
你错过了使用 ruby,你可以这样做:
rvm use 1.9.3 --install
In case 1.9.3 was not installed, this command will also install it!
如果未安装 1.9.3,此命令也会安装它!
It also looks you are using Ubuntu, make sure you are not using RVM from Ubuntu package - that thing is broken! You can find instruction how to fix it here: https://stackoverflow.com/a/9056395/497756
看起来您正在使用 Ubuntu,请确保您没有使用 Ubuntu 包中的 RVM - 那个东西坏了!您可以在此处找到如何修复它的说明:https: //stackoverflow.com/a/9056395/497756