Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RVM gem permissions error

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

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

$ 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 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?

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

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?

like image 336
Mittenchops Avatar asked Jun 18 '12 23:06

Mittenchops


1 Answers

You missed to use ruby, you can do it with:

rvm use 1.9.3 --install

In case 1.9.3 was not installed, this command will also install it!

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

like image 66
mpapis Avatar answered Nov 14 '22 23:11

mpapis