如何在RVM gemset中安装Rails 4.0?

时间:2021-12-21 20:39:17

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

我正在尝试将Rails安装到新的rvm gemset中。我尝试了以下方法:

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:

rvm gemset列表:

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 -v

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

当前未在此系统上安装Rails。要获取最新版本,只需键入:

$ sudo gem install rails

Do the rvm commands I listed not install rails 4.0?

我列出的rvm命令是不是安装了rails 4.0?

4 个解决方案

#1


75  

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.

正在创建一个基本的目录结构来保存宝石。您可以轻松地将其称为“rails-4.0”之外的其他内容,如“foo”,这将是相同的行为。

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.

切换到Ruby 2.0.0并告诉它使用名为rails-4.0的新gemset。再一次,这可能是“foo”或者你称之为的任何东西。

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

现在,要获得Rails 4.0.x,您需要:

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.

正如Barrett先前指出的那样,要获得pre / beta / rc版本,您可以指定整个版本字符串,例如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.

不要sudo,因为你不应该用rvm sudo,即使它告诉你。使用“系统ruby”(ruby不是由rvm安装),它可以以root用户身份安装,因此您需要超级用户(su)访问权限(超级用户或“sudo”)来执行此操作。但是,rvm让你以当前用户身份安装,因此你不需要sudo。

#2


15  

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版本,你就不会获得测试版或预版本,所以要获得rails 4,你需要:

gem install rails --version=4.0.0.rc1

#3


2  

Maybe try InstallRails?

也许尝试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.

http://installrails.com/是安装rails的指南,用于处理各种操作系统和设置的这些问题。它可能会对这样的事情有所帮助。

#4


0  

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

其他答案显示了使用默认ruby版本创建gemset的说明。

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

要创建gemset并使用不同的ruby版本,请按照以下说明操作:

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

假设我的机器上安装了ruby版本,默认情况下为2.2.0。

 =*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:

现在我从Github派了一个存储库,想用Rails 5(边缘版本)和Ruby 2.2.3(编写本文时的最新稳定版本)测试repo的代码。我更喜欢使用gemsets,所以我运行了以下命令:

  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:

接下来我将运行以下命令来安装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.

这应该在你上面创建的gemset中安装forked-repo中使用的gem。

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

参考:https://rvm.io/gemsets/creating

#1


75  

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.

正在创建一个基本的目录结构来保存宝石。您可以轻松地将其称为“rails-4.0”之外的其他内容,如“foo”,这将是相同的行为。

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.

切换到Ruby 2.0.0并告诉它使用名为rails-4.0的新gemset。再一次,这可能是“foo”或者你称之为的任何东西。

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

现在,要获得Rails 4.0.x,您需要:

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.

正如Barrett先前指出的那样,要获得pre / beta / rc版本,您可以指定整个版本字符串,例如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.

不要sudo,因为你不应该用rvm sudo,即使它告诉你。使用“系统ruby”(ruby不是由rvm安装),它可以以root用户身份安装,因此您需要超级用户(su)访问权限(超级用户或“sudo”)来执行此操作。但是,rvm让你以当前用户身份安装,因此你不需要sudo。

#2


15  

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版本,你就不会获得测试版或预版本,所以要获得rails 4,你需要:

gem install rails --version=4.0.0.rc1

#3


2  

Maybe try InstallRails?

也许尝试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.

http://installrails.com/是安装rails的指南,用于处理各种操作系统和设置的这些问题。它可能会对这样的事情有所帮助。

#4


0  

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

其他答案显示了使用默认ruby版本创建gemset的说明。

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

要创建gemset并使用不同的ruby版本,请按照以下说明操作:

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

假设我的机器上安装了ruby版本,默认情况下为2.2.0。

 =*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:

现在我从Github派了一个存储库,想用Rails 5(边缘版本)和Ruby 2.2.3(编写本文时的最新稳定版本)测试repo的代码。我更喜欢使用gemsets,所以我运行了以下命令:

  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:

接下来我将运行以下命令来安装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.

这应该在你上面创建的gemset中安装forked-repo中使用的gem。

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

参考:https://rvm.io/gemsets/creating