Grandpa
Grandpa

Reputation: 3223

Use multiple versions of rubygems with rvm?

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.

Each project has its own rvm gemset, but I can't figure out how to give them different versions of rubygems itself:

How can I run rubygems 1.6.2 in one project and 1.8.11 in the other?


To clarify, here's what I want to do:

Upvotes: 18

Views: 7399

Answers (2)

Tilo
Tilo

Reputation: 33732

RVM has a new feature for this:

use "rvm rubygems 1.6.2" to select that version of rubygems.

 rvm rubygems 1.6.2

https://rvm.io/rubies/rubygems/ (see: "RubyGems CLI API" towards the bottom of the page)

http://groups.google.com/group/rubyversionmanager/browse_thread/thread/e39fc7827d2d22e8

Upvotes: 9

ddd
ddd

Reputation: 1985

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

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).

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.

Upvotes: 19

Related Questions