16

On a clean Mac OS X "Snow Leopard" install, I have a problem with RVM: It sets the Ruby path correctly but doesn't set the gem path. When I start a Rails server it mixes versions which doesn't work.

To illustrate:

$ rvm system
$ which ruby
/usr/bin/ruby
$ which rails
/usr/bin/rails
$ rvm use 1.9.2-head
Using /Users/m/.rvm/gems/ruby-1.9.2-head
$ rvm gem list

LOCAL GEMS
[...]
rails (3.0.7)
[...]

$ which ruby
/Users/m/.rvm/rubies/ruby-1.9.2-head/bin/ruby
$ which rails
/usr/bin/rails

$ echo $GEM_PATH
/Users/m/.rvm/gems/ruby-1.9.2-p180:/Users/m/.rvm/gems/ruby-1.9.2-p180@global

$ echo $PATH
/Users/m/.rvm/gems/ruby-1.9.2-p180/bin:/Users/m/.rvm/gems/ruby-1.9.2p180@global/bin:/Users/m/.rvm/rubies/ruby-1.9.2p180/bin:/Users/m/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

Any ideas what might be wrong?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
m..
  • 161
  • 1
  • 1
  • 7
  • did you do 'gem install rails' after you did 'rvm use 1.9.2-head' ?? – Tilo May 08 '11 at 05:36
  • it looks like you're using a previous rails version which came with OS X -- and which was not installed under RVM – Tilo May 08 '11 at 05:37
  • I am also on fresh install of OS X & rvm & ruby 1.9.2. I am not using gemsets, just typing `rvm 1.9.2`. As far as I remember, I have installed bundler with `gem install` and it has been installed in correct location: `~/.rvm/gems/ruby-1.9.2-p290/bin/`; `which bundle` points to this location. All remaining gems were installed with bundler and they are placed in `~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/`. This location is not present in $GEM_PATH nor its bin is present in $PATH. Please check this location, maybe you'll find your gems there. BTW `bundle exec` works for me. – skalee Oct 12 '11 at 12:10

3 Answers3

12

So after 1 1/2 days of torture, reading through at least 50 posts, and installing RVM, Ruby and Rails multiple times, I am finally able to use Rails in my RVM install.

This was the last series of events that I did after installing RVM and Ruby the last time and then it worked:

I removed these from .gemrc so back up your file if you do this:

  • gemhome: /home/[user]/ruby/gems
  • gempath: []
  • --remote

then use

rvm use 1.9.3 --default

then

gem install rails

It seems the trick was:

  1. Change the .gemrc file.
  2. Do not create and use a gemset (rvm use 1.9.3@rails3) before installing Rails.
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Chris Simeone
  • 755
  • 1
  • 10
  • 26
5

Make sure you're always 'using' your Ruby version. (Ugh. RVM can be so annoying).

rvm use 1.9.3 --default

Also what does your .gemrc look like? I had to take out --user from mine.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
nnyby
  • 4,748
  • 10
  • 49
  • 105
1

Make sure you do a gem install rails after setting the default Ruby version:

  rvm use 1.9.2-head
  gem install rails

and then check again with which rails.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Tilo
  • 33,354
  • 5
  • 79
  • 106
  • 1
    I did that, of course. Still haven't figured this out, but got a new computer in the meantime, so I cannot reproduce the problem. – m.. Jun 09 '11 at 19:32
  • I saw a similar problem when having rvm use the ruby version from a local .rvmrc file ... in this case the paths were not set correctly, and you need to do: rvm use ... – poseid Sep 15 '11 at 12:28