문제

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:

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.

This is my gem directory:

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:

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?

도움이 되었습니까?

해결책

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.

다른 팁

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.

It is much better to create a individual gemset for that project then make sure you own it with 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

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

If you don't own it then chown it to your user

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.

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. 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:

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. When I opened access, I no longer got Errno::EACCES messages. 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.

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. 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.

What's your path look like? It sounds like you're getting a system version of gem instead of the rvm-based command.

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. Run ruby --version to make sure it is as expected.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top