Bugs: Browse | Submit New | Admin

[#1379] require fails for extensions with multiple directories listed in require_paths

2005-01-23 02:02
Submitted By:
Lyle Johnson (lyle)
Assigned To:
Nobody (None)
require fails for extensions with multiple directories listed in require_paths

Detailed description
I've hit on a bug in Gem::GemPathSearcher#matching_file that will probably break any Gem that has more than one directory
listed in its require_paths. This bug is present in version 0.8.4. This one may be related to some of the other bugs
already reported for custom_require.rb but I'm not sure.

The require_paths for the FXRuby gem are defined thusly in the GemSpec:

  spec.require_paths = ['ext/fox12', 'lib']

and the name of the extension that users will try to 
The Gem::GemPathSearcher#find method iterates over all of the specifications, calling matching_file(spec, path). The
first line of matching_file() defines a glob pattern using this template:

  glob = "#{@lib_dirs[spec.object_id]}/#{path}#{SUFFIX_PATTERN}"

which for this case expands to the string:

  glob = "c:/ruby-1.8.2/lib/ruby/gems/1.8/gems/fxruby-1.2.3-mswin32/ext/fox12,lib/fox12{,.rb,.so,.bundle,.dll,.sl}

and when that pattern is passed into Dir.glob it of course returns an empty array. Part of the problem is that
the @lib_dirs[spec.object_id] value has been defined incorrectly, but I guess there's more to it than that.

I'll check out the CVS shortly and see if I can cook up a patch, but I wanted to go ahead and get this one in the system.
Not really sure how to work around it.

Add A Comment: Notepad

Please login


Date: 2006-12-13 03:36
Sender: Eric Hodel

Fixed some time ago.
Date: 2005-01-23 02:31
Sender: Lyle Johnson

Logged In: YES 

OK, looks like a one-line fix is all that's needed. I uploaded
a patch (see http://rubyforge.org/tracker/index.php?func=detail&a
mp;aid=1380&group_id=126&atid=577) but you just want
to modify the return value of Gem::GemPathSearcher#lib_dirs so
that it surrounds the require_paths values with braces, so that
Dir.glob will do the right thing if there's more than one directory
listed in the require_paths. Corrected return value should look
like this:



Attached Files:

Name Description Download
No Files Currently Attached


Field Old Value Date By
status_idOpen2006-12-13 03:36drbrain
resolution_idNone2006-12-13 03:36drbrain
close_date2006-12-13 03:362006-12-13 03:36drbrain