Having a local copy of a gem - how to handle require_gem?

In order to resolve namespace conflicts, I need to take ownership of two
Rubygems.

This mean that I would like to take these gems, and put them in local,
self-managed folders so that I can control their namespaces.

I am able to successfully require these modules, however, I can’t get
the “require_gem” call to work.

Should I be able to pass any arbitrary path that is not in my load path
to a gem to require_gem and expect it to work?

Example:

require_gem “${RAILS_ROOT}/app/modules/whatever.rb”

Does require_gem only look on the load path? Would I need to add
${RAILS_ROOT}/app/modules to my Ruby load path?

Thanks,
Wes

On 5/18/06, Wes G. [email protected] wrote:

In order to resolve namespace conflicts, I need to take ownership of two
Rubygems.

Do not use require_gem unless you wish to set a particular version.
Even then, I would argue against because it still uses the
“autorequire” functionality that will be removed eventually.

(IMO, a new verson of RubyGems should be released soon that has
activate_gem that does not use autorequire and deprecates
require_gem.)

You have to specify the name of the gem to use require_gem; require
can be used to specify a full path.

-austin

Wes G. wrote:

In order to resolve namespace conflicts, I need to take ownership of two
Rubygems.

This mean that I would like to take these gems, and put them in local,
self-managed folders so that I can control their namespaces.

I am able to successfully require these modules, however, I can’t get
the “require_gem” call to work.

I believe require_gem is outdated.

Gem files are tarballs, containing two tgz archives. The data.tgz file
has the code. Unpack this into a local directory, and push the path
into the Ruby load path.

$:.unshift( ‘/path/to/unpacked/gem/lib’ )

For Rails, I believe that placing unpacked gems into the vendor dir
allows this to be handled for you. (It’s referred to, I think as
‘freezing’ a gem. It’s very handy.)

You’ll get better information on that on the Rails mailing list.


James B.

http://web2.0validator.com - We’re the Dot in Web 2.0
http://refreshingcities.org - Design, technology, usability
http://yourelevatorpitch.com - Finding Business Focus
http://www.jamesbritt.com - Playing with Better Toys