5

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?

Mittenchops
  • 18,633
  • 33
  • 128
  • 246
  • Someone will probably need an `ls -la /var/lib/gems/1.9.1` from the command line to figure out the current permissions on the directory. Also perhaps `whoami` to see the current user. – buley Jun 19 '12 at 00:01
  • Permissions are 755, but I think the issue is that I'd rather have this installed outside of var, right? var ought to be owned by root. Shouldn't this only be located in the home/username directory? – Mittenchops Jun 19 '12 at 01:22

1 Answers1

7

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

Community
  • 1
  • 1
mpapis
  • 52,729
  • 14
  • 121
  • 158
  • I'd also check out [rvmrc files](https://rvm.io//workflow/rvmrc/), which can be useful to automatically use versions of ruby and gemsets as you traverse your file system. – fdsaas Jun 19 '12 at 00:18
  • I think there was no research at all, best start is at https://rvm.io, it provides best set of information - updated to reflect current state of RVM. – mpapis Jun 19 '12 at 00:34
  • 1
    `$rvm use 1.9.3 --install RVM is not a function, selecting rubies with 'rvm use ...' will not work. You need to change your terminal settings to allow shell login. Please visit https://rvm.io/workflow/screen/ for example.` – Mittenchops Jun 19 '12 at 01:01
  • It looks like ruby is installed. – Mittenchops Jun 19 '12 at 02:03
  • @Mittenchops you need to follow the instructions, I guess in your case https://rvm.io/integration/gnome-terminal/ is more appropriate. – mpapis Jun 19 '12 at 02:03
  • That worked, but only after a reboot which threw me off. Thanks! – Mittenchops Jun 20 '12 at 16:57