[Rubygems-developers] Gem Names not correlated to require name

Jim Freeze rubygems at freeze.org
Tue Sep 30 21:03:40 EDT 2008

On Tue, Sep 30, 2008 at 5:42 PM, Jim Weirich <jim.weirich at gmail.com> wrote:
> On Sep 30, 2008, at 4:51 PM, Jim Freeze wrote:
>> One way (just one, mind you) is that if require_gem really required
>> the gem. So, you would have
>>  require_gem 'gem_name_here'
>> and the gem did the requiring of the files internal.
> NO!  That way leads to madness.
> That was the function of the autorequire flag on older gemspecs.  That lead
> to early loading of code before the complete gem version requirements were
> given.  This could lead to incompatible version of the library being
> required.
> It was also the root cause of causing require "FILE" to return false instead
> of true.  A bug the pragmatically effected absolutely no one (who checks the
> return value of require?), but caused no end of questions because people
> would do a require in irb and see the false and think the file wasn't
> loaded.
> The autorequire flag was also the root cause of several other issues which
> escape me at the moment.


So, I did not realize that require_gem was such a loaded word.  And
somehow is sucked in autorequire. Who mentioned that?

So, I am not surprised that there is no require_gem because there
never was a require_gem 'gem_name'.

So, to avoid any harmful effects of require_gem, I'm suggesting a new
method. Let's call it bunny_foo_foo. That is surely a harmless method.

This whole conversation started because I've been bombarded with
complaints that rubygems is broken because there is no way to know
what to require after installing a gem. In fact, these 'unnamed
individuals' have identified the problem as two separate problems, 1)
the naming of the gem and 2) the naming/path of the file to require.

I really don't see a way around #1. I mean, how can you possibly know
that the chunky_bacon gem is used for python comment parsing.

But, the second issue is potentially solvable, but it will require an
addition of an optional file (or possibly hook code) to a gem.

So, a standard scenario would be this:

 sudo gem install bora_bora

Then, in the ruby code we would have

 bunny_foo_foo 'bora_bora'

Is that too abstract? Today, gem developers can solve this problem in
the following manner:

 sudo gem install bora_bora
 require 'rubygems'
 require 'bora_bora'  # look, no surprise here.

where the bora_bora gem has included the file lib/bora_bora.rb with the contents

 require 'my/crazy/path/that/you/cant/guess'

But, we can refactor these two lines into a single line

 require_gem 'bora_bora'

I mean

 bunny_foo_foo 'bora_bora'  # optional version follows

So, here the file lib/bora_bora does not have to exist. It could
possibly be lib/bootstrap.rb. This file will then require the correct
files. You know, the mysterious ones that I've been getting complaints

Also, notice there is no suggestion of autorequire here. This simply
replaces the "require 'secret/path'".

Jim Freeze

More information about the Rubygems-developers mailing list