13

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?

Syed Aslam
  • 8,707
  • 5
  • 40
  • 54
  • Also found a weird thing happening now. When I open a new shell, the ruby version should be the one which is installed system-wide (i.e., ruby-1.8.7) isn't it? But, it is giving me 1.9.2 and I have to do rvm system to come back to that. – Syed Aslam Nov 29 '10 at 11:17
  • Very oddd. Try `chmod -R u+w /home/syed/.rvm` – aceofspades Nov 29 '10 at 18:19

7 Answers7

18

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.

user531510
  • 204
  • 1
  • 3
  • Should a modification request be submitted to deal with this? Very confusing for beginners and no mention of this problem in current tutorials. – AJP Feb 11 '12 at 14:59
  • 2
    It's a very bad idea to use chmod 777 for this purpose. Use `chown` instead. – user2398029 Feb 28 '13 at 04:58
  • This maybe you previously installed rubygems, I tried to removed $HOME/.gem directory, and it also works. – Evans Y. Apr 09 '13 at 01:59
5

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
upisdown
  • 309
  • 4
  • 7
3

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
fifigyuri
  • 5,771
  • 8
  • 30
  • 50
  • I tried this earlier: $ rvm use --create 1.9.2@rails3 But, it is throwing up same errors. It is taking /home/syed/.gem/specs as the gem directory instead of /home/syed/.rvm/gems/ruby-1.9.2-p0@rails3. I don't know why. – Syed Aslam Nov 29 '10 at 11:24
  • That's strange, it is supposed to work without any permission problems. Check your permissions thoroughly again.. – fifigyuri Nov 29 '10 at 12:18
2

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.

Dr. Rajesh Rolen
  • 14,029
  • 41
  • 106
  • 178
kstars
  • 21
  • 1
2

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.

pcg79
  • 1,283
  • 9
  • 20
1

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.

bcoughlan
  • 25,987
  • 18
  • 90
  • 141
1

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

Keith Gaddis
  • 4,113
  • 23
  • 20
  • My path: /home/syed/.rvm/gems/ruby-1.9.2-p0/bin:/home/syed/.rvm/gems/ruby-1.9.2-p0@global/bin:/home/syed/.rvm/rubies/ruby-1.9.2-p0/bin:/home/syed/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games – Syed Aslam Dec 01 '10 at 05:43