我正在使用rubygems和rvm,它工作得非常好但是现在当我尝试安装gem时出现错误
gem install railsERROR:同时 执行宝石......(Errno :: EACCES) 许可被拒绝 - /Users/da/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.11/.gitignore
当我做sudo时它起作用,但我在安装gem之前从未这样做过。
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.7.0]
- INSTALLATION DIRECTORY: /Users/da/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /Users/da/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /Users/da/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/da/.rvm/gems/ruby-1.9.2-p180
- /Users/da/.rvm/gems/ruby-1.9.2-p180@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
$ sudo gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.7.0]
- INSTALLATION DIRECTORY: /Users/da/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /Users/danest/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /Users/da/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/da/.rvm/gems/ruby-1.9.2-p180
- /Users/da/.rvm/gems/ruby-1.9.2-p180@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
答案 0 :(得分:30)
看起来您已将root用户设置为使用主文件夹中的rvm install。这意味着当您使用sudo安装gem时,这些文件将属于root。因此,当您尝试像您一样安装gem时,您将收到权限错误。
要解决此问题,您需要将rvm文件夹改回给您(我假设,从您的文件路径中,您的用户名是'da')...
sudo chown -R da:da /Users/da/.rvm
为了避免将来发生这种情况,我建议将root的路径设置为自己安装的rvm或系统gem。