How do you install Rails 4.0 in an RVM gemset?

心已入冬 提交于 2019-11-29 20:11:04

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.

Barrett Clark

In addition to the usage tips above, if you don't specify the gem version you won't get the beta or pre version, so to get rails 4, you need:

gem install rails --version=4.0.0.rc1

Maybe try InstallRails?

http://installrails.com/ is a guide for installing rails that deals with these issues for various Operating Systems and setups. It might prove helpful for something like this.

Other answers shows instructions for creating the gemset using default ruby version.

For creating a gemset and use it with different ruby version please follow the instructions below:

Let's say on my machine I have following ruby versions installed and 2.2.0 is the default.

 =*ruby-2.2.0 [ x86_64 ]
   ruby-2.2.1 [ x86_64 ]
   ruby-2.2.3 [ x86_64 ]

Now I have forked a repository from Github and want to test out the repo's code with Rails 5 (edge version) and Ruby 2.2.3 (the latest stable version at the time of this writing). And I prefer using gemsets so I ran following commands:

  rvm use 2.2.3@forked-repo --create

That's actually a shortcut for

  rvm 2.2.3
  rvm gemset create forked-repo

Next I would run following command to install bundler:

  forked_repo_root$ gem install bundler     
  forked_repo_root$ bundle

That should install the gems used in your forked-repo in the gemset created above.

Reference: https://rvm.io/gemsets/creating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!