[Rubygems-developers] requiring gems

Richard Kilmer rich at infoether.com
Thu Sep 2 14:03:57 EDT 2004

On 9/2/04 1:08 PM, "Jamis Buck" <jgb3 at email.byu.edu> wrote:

> I've been lurking on the list alot, and recently there was a discussion
> about removing the stub files that get installed for gems, in favor of
> using the RUBYOPTS variable to cause rubygems to be autoinstalled.

Right...RUBYOPT would 'require "rubygems"' and then...

> This works fine for gems that are accessed at the "top level" (ie,
> "require 'copland'", "require 'activerecord'", and so forth), but what
> about gems that want to behave as if they are "add-ons" to an existing
> directory? I'm thinking of the net-ssh gem, which wants to be required
> as 'net/ssh'.

It actually now works across ANY file in ANY gem (in version sorted order).
So, as a developer, you just put your files in the lib dir of your gem (or
wherever) and then with the above mentioned RUBYOPT, you can just do:

require 'net/ssh'

And the new loadpath_manager searches all the gems for a file that matches
and then require_gem's that gem, then does a regular require of net/ssh.
This allows rubygems to be transparent.  Basically think of it as merging
the lib paths of all the gems into one search space and finding based on
your require (like ruby itself does now across the LOAD_PATH).

> With the RUBYOPTS approach, would this still work? A quick test on my
> box seems to fail, but I don't have the 'ubygems' require hack
> installed... Would that fix it?

Right, you need the CVS version of rubygems or wait until we release (SOON
SOON) 0.8.0.  Its not 'ubygems'...that just allows the setting of:

set RUBYOPT='rubygems'


set RUBYOPT='rrubygems'


> - Jamis

More information about the Rubygems-developers mailing list