Require a specific gem-version


I have a question about how to include a special version of a gem.

On my server there are two versions of RedCloth: 3.0.3 and 3.0.4.

And I need to use 3.0.3.

If I write a script, I can simply write it like this:
require ‘rubygems’
require_gem ‘RedCloth’, ‘3.0.3’

But if I put "require_gem ‘RedCloth’, ‘3.0.3’ " as first line into
environment.rb, I get this error:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:196:in `activate’: can’t
activate RedCloth (= 3.0.3), already activated RedCloth-3.0.4]

Can you please tell me, where I can define the versions Rails should

Johannes Held

I’ve been solving this problem by requiring RedCloth before the
loop in config/environment.rb. YMMV but it works for me.

The question I want to add here is that now that [or as soon as]
has been officially deprecated, what’s the right way to require a
version of a gem using a regular require? RTFM, right? Hehehe. I know.
been “looking” but haven’t run across the way yet. Excuse me if it’s


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs