0

When I try to create a new Rails app in the directory in which I keep all my Rails apps, I get the following error:

Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

I've recently been working with an RVM tutorial, so I thought it might have something to do with a gemset I had created. I typed 'rvm gemset list' and found the following:

gemsets for system (found in /Users/rickthomas/.rvm/gems/system)
=> (default)
   *

But the weird thing is, I cd'ed into the directory of one of the apps, and ran the same command, and found this:

gemsets for ruby-1.9.3-p429 (found in /Users/rickthomas/.rvm/gems/ruby-1.9.3-p429)
=> (default)
   global

When I run the 'rails --version' command in the main directory, I get the message to run 'sudo gem install rails', but when I run the same command from within the app directory, I get this:

Rails 3.2.12

Kinda confused why I all of a sudden can't create a new Rails app, since the last one I created was this morning, a day after I finished the RVM tutorial, and didn't make any gemset changes since then.

Richie Thomas
  • 3,073
  • 4
  • 32
  • 55

1 Answers1

1

It looks like your "system" ruby doesn't have the Rails gem installed. You probably don't want to be using the system ruby anyway. How about you try this:

rvm use 1.9.3      # switch to your Ruby 1.9.3 that the other app used
gem list           # make sure rails is listed
gem install rails  # (only if rails was not listed)
rails new myapp

There is nothing weird about the "weird thing" you observed. When you cd into a directory, RVM looks at files like .rvmrc, .ruby-version, and .ruby-gemset in that directory and it automatically changes your environment to match. You can run "rvm info" to see what kind of environment you are currently in (I usually focus on the GEM_HOME and GEM_PATH variables). In this case, cd'ing into your Rails app directory caused RVM to switch you to Ruby 1.9.3, and that's the Ruby where you had the rails gem installed. Seems normal to me.

David Grayson
  • 84,103
  • 24
  • 152
  • 189
  • Thanks. Any idea why I would no longer be able to generate a Rails app in the parent directory when I had previously been able to do so? I don't remember using the 'rvm use' command to switch to a previous version. – Richie Thomas Nov 01 '13 at 01:28
  • You probably did run "rvm use 1.9.3" in your terminal when you created the previous app so then you set your terminal up to generally use 1.9.3 instead of the system ruby. Or maybe you ran "rvm install 1.9.3" and it automatically switched to the new ruby for you? – David Grayson Nov 01 '13 at 01:33
  • Hmm, well in any case I just ran 'rvm use 1.9.3 --default' in hopes that I won't have this problem again, at least for this reason. Does that sound logical? – Richie Thomas Nov 01 '13 at 01:35
  • Yeah, that sounds logical to me. – David Grayson Nov 01 '13 at 01:37