can't install new Rails app; RVM 'global' gemset missing from main directory but visible in app sub-directories

StackOverflow https://stackoverflow.com/questions/19719351

Frage

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.

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top