Ruby-on-rails – How to install Rails 4.0 in an RVM gemset

ruby-on-railsrvm

I am trying to install Rails into a new rvm gemset.
I tried the following:

rvm gemset create rails-4.0
output: gemset created rails-4.0

Next I did:

rvm 2.0.0@rails-4.0

rvm gemset list:

gemsets for ruby-2.0.0-p0 (found in /Users/me/.rvm/gems/ruby-2.0.0-p0)
   (default)
   global
=> rails-4.0

rails -v

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

$ sudo gem install rails

Do the rvm commands I listed not install rails 4.0?

Best Answer

This command:

rvm gemset create rails-4.0

is creating basically a directory structure to hold the gems. You could have just as easily called it something other than "rails-4.0" like "foo" and it would be the same behavior.

This command:

rvm 2.0.0@rails-4.0

Switches to Ruby 2.0.0 and tells it to use the new gemset named rails-4.0. Again, that could be "foo" or whatever you called it.

Now, to get Rails 4.0.x, you'd do:

gem install rails --version=4.0

As Barrett pointed out earlier, to get a pre/beta/rc release, you can specify the whole version string, e.g. gem install rails --version=4.0.0.rc2.

Don't sudo, because you shouldn't sudo with rvm, even though it tells you to. With the "system ruby" (ruby not installed by rvm), it may be installed as root, so you need superuser (su) access (superuser do or "sudo") to do that. But, rvm has you install things as the current user, therefore you don't need to sudo.