tags:

views:

40

answers:

1

I have several versions of a Ruby gem installed on my machine. I'm using one version for development, but the other is used for production and deployment, so I need them both. Is there a simple way to specify which version of the gem should be used?

Since they are the same gem, their binary names conflict, and I have to physically remove one or the other from the gems directory and leave the other one that I want to keep active. But I'd like to be able to jump back and forth between development and production gems, and I am hoping there is a better way.

Edit: I guess I should have make it more clear. When I said development, I meant development of the gem, not the "Rails development environment." So what I'm doing is I forked a gem from Github, and I am using both my fork and the original gem from the commandline. Not as part of Rails.

+1  A: 

See the Rubygems manual. Pretty sure this is still valid in Rails 3.

For example:

require 'rubygems'
gem 'activerecord', '= 1.4.0'

Other valid operators (in lieu of =) are >, >=, <, <=; I believe they also take the ~ modifier.

mway
No no, I don't want to use it as part of Rails. I need to use the gems from the commandline.
picardo
The answer is still valid. See http://docs.rubygems.org/read/chapter/4#page71 for the authoritative answer in the RubyGems manual.
joschi
Do you mean `~>`, not `~`?
Andrew Grimm