I have two projects on my computer: - An old Rails 2.3 app that needs rubygems 1.6 and won't run under rubygems 1.8; - A newer app that needs rubygems 1.8 and won't run under rubygems 1.6.
我的计算机上有两个项目: - 一个需要rubygems 1.6的旧Rails 2.3应用程序,不会在rubygems 1.8下运行; - 一个需要rubygems 1.8的新应用程序,不会在rubygems 1.6下运行。
Each project has its own rvm gemset, but I can't figure out how to give them different versions of rubygems itself:
每个项目都有自己的rvm gemset,但我无法弄清楚如何给它们不同版本的rubygems本身:
- gem update --system [version] results in gem --version giving the same answer in both;
- gem update --system [version]导致gem --version在两者中给出相同的答案;
- rvm gemset [version] has the same result.
- rvm gemset [version]具有相同的结果。
How can I run rubygems 1.6.2 in one project and 1.8.11 in the other?
如何在一个项目中运行rubygems 1.6.2,在另一个项目中运行1.8.11?
To clarify, here's what I want to do:
澄清一下,这就是我想要做的事情:
- In directory A, have a .rvmrc with commands that select gemset A and rubygems 1.6.2
- 在目录A中,有一个.rvmrc,其命令选择gemset A和rubygems 1.6.2
- In directory B, have a .rvmrc with commands that select gemset B and rubygems latest
- 在目录B中,有一个.rvmrc,其中包含最新选择gemset B和rubygems的命令
- Have two terminal sessions open at the same time, one in directory A and the other in directory B
- 同时打开两个终端会话,一个在目录A中,另一个在目录B中
- Type "gem --version" in directory A and see "1.6.2"
- 在目录A中输入“gem --version”并查看“1.6.2”
- Type "gem --version" in directory B and see "1.8.11"
- 在目录B中输入“gem --version”并查看“1.8.11”
2 个解决方案
#1
17
The correct way is to created different named (-n) installs of the ruby you want installed and name them according to the rubygem version you want such as
正确的方法是创建您想要安装的ruby的不同命名(-n)安装,并根据您想要的rubygem版本命名它们,例如
rvm --install use 1.9.2-nrg186 && rvm rubygems 1.8.6 && gem --list
rvm --install use 1.9.2-nrg1810 && rvm rubygems 1.8.10 && gem --list
The reason for this is that you can only have 1 version of rubygems active an any given time. This is also due to the fact that each ruby defines a dependency on a specific rubygems version that version is known or expected to work with (regardless of if it can work with another or not).
原因是您在任何给定时间内只能激活1个版本的rubygems。这也是由于每个ruby都定义了对特定rubygems版本的依赖性,该版本已知或预期可以使用(无论它是否可以与其他版本一起使用)。
This is the expected way to handle the multiple rubygems requirement and to eliminate potential problems. See https://gist.github.com/1273035 for specifics detailing this.
这是处理多个rubygems要求并消除潜在问题的预期方法。有关详细说明,请参阅https://gist.github.com/1273035。
#2
9
RVM has a new feature for this:
RVM有一个新功能:
use "rvm rubygems 1.6.2" to select that version of rubygems.
使用“rvm rubygems 1.6.2”来选择该版本的rubygems。
rvm rubygems 1.6.2
https://rvm.io/rubies/rubygems/ (see: "RubyGems CLI API" towards the bottom of the page)
https://rvm.io/rubies/rubygems/(参见页面底部的“RubyGems CLI API”)
http://groups.google.com/group/rubyversionmanager/browse_thread/thread/e39fc7827d2d22e8
http://groups.google.com/group/rubyversionmanager/browse_thread/thread/e39fc7827d2d22e8
#1
17
The correct way is to created different named (-n) installs of the ruby you want installed and name them according to the rubygem version you want such as
正确的方法是创建您想要安装的ruby的不同命名(-n)安装,并根据您想要的rubygem版本命名它们,例如
rvm --install use 1.9.2-nrg186 && rvm rubygems 1.8.6 && gem --list
rvm --install use 1.9.2-nrg1810 && rvm rubygems 1.8.10 && gem --list
The reason for this is that you can only have 1 version of rubygems active an any given time. This is also due to the fact that each ruby defines a dependency on a specific rubygems version that version is known or expected to work with (regardless of if it can work with another or not).
原因是您在任何给定时间内只能激活1个版本的rubygems。这也是由于每个ruby都定义了对特定rubygems版本的依赖性,该版本已知或预期可以使用(无论它是否可以与其他版本一起使用)。
This is the expected way to handle the multiple rubygems requirement and to eliminate potential problems. See https://gist.github.com/1273035 for specifics detailing this.
这是处理多个rubygems要求并消除潜在问题的预期方法。有关详细说明,请参阅https://gist.github.com/1273035。
#2
9
RVM has a new feature for this:
RVM有一个新功能:
use "rvm rubygems 1.6.2" to select that version of rubygems.
使用“rvm rubygems 1.6.2”来选择该版本的rubygems。
rvm rubygems 1.6.2
https://rvm.io/rubies/rubygems/ (see: "RubyGems CLI API" towards the bottom of the page)
https://rvm.io/rubies/rubygems/(参见页面底部的“RubyGems CLI API”)
http://groups.google.com/group/rubyversionmanager/browse_thread/thread/e39fc7827d2d22e8
http://groups.google.com/group/rubyversionmanager/browse_thread/thread/e39fc7827d2d22e8