简体   繁体   English

RVM的权限被拒绝错误

[英]Permission denied error with RVM

I have searched for this problem and couldn't find relevant similar questions. 我搜索过这个问题,找不到相关的类似问题。 Please bear with me if this is repetitive. 如果重复,请耐心等待。

I have followed guides in RVM website to install RVM and I have installed rubies: 我已经按照RVM网站中的指南安装RVM并且我已经安装了rubies:

syed@rails:~$ rvm list

rvm rubies

   ruby-1.8.7-p302 [ i386 ]
=> ruby-1.9.2-p0 [ i386 ]

As you can see I have made ruby-1.9.2 my default. 正如您所看到的,我将ruby-1.9.2设为默认值。

This is my gem directory: 这是我的gem目录:

syed@rails:~$ rvm gemdir
/home/syed/.rvm/gems/ruby-1.9.2-p0

Now, I tried to install rails and I am thrown the following error: 现在,我试图安装rails,我抛出以下错误:

syed@rails:~$ gem install rails
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /home/syed/.gem/specs

I even did this without making any difference to the error: 我甚至做了这个,没有对错误产生任何影响:

syed@rails:~$ chown -R syed /home/syed/.rvm/

Currently, my environment looks like this: 目前,我的环境看起来像这样:

syed@rails:~$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i686-linux]
  - INSTALLATION DIRECTORY: /home/syed/.rvm/gems/ruby-1.9.2-p0@rails3
  - RUBY EXECUTABLE: /home/syed/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
  - EXECUTABLE DIRECTORY: /home/syed/.rvm/gems/ruby-1.9.2-p0@rails3/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/syed/.rvm/gems/ruby-1.9.2-p0@rails3
     - /home/syed/.rvm/gems/ruby-1.9.2-p0@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

I don't understand why it is trying to install gems to my system gem directory path? 我不明白为什么它试图将gems安装到我的系统gem目录路径?

I had this same problem and I resolved it by doing the following: 我有同样的问题,我通过执行以下操作解决了这个问题:

sudo mkdir ~/.gem/specs
sudo chmod 777 ~/.gem/specs

It seems that RVM was trying to create this "specs" folder, but didn't have permissions to do so. 似乎RVM试图创建这个“specs”文件夹,但没有权限这样做。

I really don't like the accepted answer, its a hack not a solution suitable for production. 我真的不喜欢接受的答案,它不是适合生产的解决方案。 When you chmod 777 you are giving anyone on the machine access complete access to those folders. 当你chmod 777你给机器上的任何人访问完全访问这些文件夹。

It is much better to create a individual gemset for that project then make sure you own it with chown. 为该项目创建单独的gemset要好得多,然后确保使用chown来拥有它。

rvm gemset create project
rvm use ruby-1.9.3-p394@project # May not be necessary

And in your gems folder, for the case above "home/syed/.rvm/gems/" make sure the new gemset you created is owned by you 在您的gems文件夹中,对于上面的情况“home / syed / .rvm / gems /”,请确保您创建的新gemset由您拥有

cd home/syed/.rvm/gems/ && ls -la 

If you don't own it then chown it to your user 如果你不拥有它,那么将它chown给你的用户

sudo chown -R user:rvm gemset

Maybe try to check also the " chown " permissions for the necessary files/directories to find out more about your error message. 也许尝试检查必要文件/目录的“ chown ”权限,以找到有关错误消息的更多信息。

Usually I create gemset for the different applications/projects so I don't get a mixture of hundreds of different gems at one place after few weeks/months. 通常我会为不同的应用程序/项目创建gemset,这样我就不会在几周/几个月后在一个地方混合使用数百种不同的宝石。 Try this: 尝试这个:

rvm use 1.9.2
rvm gemset create YOURGEMSETNAME
rvm gemset use YOURGEMSETNAME

or simply 或者干脆

rvm 1.9.2@YOURGEMSETNAME --create

Try to install your gems after that. 之后尝试安装你的宝石。 If your want the gems appear for every gemset for ruby 1.9.2, than switch to the global gemset and install your gems there: 如果你想要为ruby 1.9.2的每个gemset显示宝石,那么切换到全局 gemset并在那里安装你的宝石:

rvm 1.9.2@global
gem install rails3 # or whatever you wish

I solved this one, finally. 我终于解决了这个问题。 It turns out that my firewall was blocking 199.91.171.93. 事实证明我的防火墙阻止了199.91.171.93。 When I opened access, I no longer got Errno::EACCES messages. 当我打开访问权限时,我不再收到Errno::EACCES消息。 I diagnosed this by using --verbose and I could see the source was trying to update the $HOME/.gem/specs/rubygems.org%80/quick/Marshal.4.8 area, but could not simply because the traffic was blocked. 我通过使用--verbose诊断出这一点,我可以看到源代码正在尝试更新$ HOME / .gem / specs / ruby​​gems.org%80 / quick / Marshal.4.8区域,但不能简单地因为流量被阻止。

I just had this problem and wanted to record my answer for posterity. 我刚遇到这个问题,想要为后代记录我的答案。 All of the directories in my Ruby-specific RVM directory were owned by root. 特定于Ruby的RVM目录中的所有目录都归root所有。 So I had to chown all of them. 所以我不得不把它们全都打扮出来。

~/.rvm/gems/ruby-1.9.3-p286

drwxr-xr-x  22 root           staff   748 Nov 12 13:34 bin
drwxr-xr-x   2 root           staff    68 Nov 20 14:42 cache
drwxr-xr-x   2 root           staff    68 Nov  1 09:59 doc
drwxr-xr-x  47 root           staff  1598 Nov 12 13:34 gems

I don't know if this is normal but after changing them all to my non-root user the problem went away. 我不知道这是否正常但是在将它们全部更改为我的非root用户之后问题就消失了。

For those coming from Google: On Windows I had this problem because I had an older version of Ruby installed in my Program Files directory, which newer versions of Windows have security restrictions on. 对于那些来自谷歌的人:在Windows上我遇到了这个问题,因为我在我的Program Files目录中安装了旧版本的Ruby,新版本的Windows有安全限制。 Run ruby --version to make sure it is as expected. 运行ruby --version以确保它符合预期。

What's your path look like? 你的路径是什么样的? It sounds like you're getting a system version of gem instead of the rvm-based command. 听起来你正在获得gem的系统版本,而不是基于rvm的命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM