Require a specific gem-version


#1

Hello,

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]
(Gem::Exception)

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

Johannes Held


#2

I’ve been solving this problem by requiring RedCloth before the
Initializer
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]
require_gem
has been officially deprecated, what’s the right way to require a
specific
version of a gem using a regular require? RTFM, right? Hehehe. I know.
I’ve
been “looking” but haven’t run across the way yet. Excuse me if it’s
obvious.

RSL