[Rubygems-developers] 'require_gem' with ambiguous names...
jgb3 at email.byu.edu
Mon Sep 13 10:39:10 EDT 2004
Gavin Sinclair wrote:
> On Monday, September 13, 2004, 2:34:38 PM, Jamis wrote:
>>Disclaimer: I'm still using 0.7, so I don't know if this is fixed in 0.8.
>>I've got four gems: copland, copland-lib, copland-remote, and
>>copland-webrick. When I do a "require_gem 'copland'", all four of those
>>match, and because 'copland-webrick' is the last one in the list, it is
>>the one that gets required. Fortunately, copland-webrick has a
>>dependency on copland, so all works out okay, but it wasn't quite what I
>>Is this already fixed?
> Are you saying that require_gem is inexact in its behaviour? If so,
> wow... dunno if it's fixed.
> Where are these four gems you've got? Are they planned releases?
Already released, in fact. And in the gem repository.
I discovered the problem like this:
1) Install copland and copland-webrick gems.
2) Start irb.
3) Do 'require "copland"' (or 'require_gem "copland"', either works)
4) Inspect the value of Copland::LIBRARIES.keys
The Copland::LIBRARIES variable is a hash of search paths that Copland
can use for finding installed packages. Given the above use case, it
_should_ contain only a single key, "copland". However, with 0.7, I get
two keys, "copland" and "copland/webrick".
I put some debugging in my copy of rubygems.rb, in the "require_gem"
method, and it looks like all of the copland* gems are matching when I
do a 'require_gem "copland"' (without an explicit version). Then, it
grabs the last one in the list, which is theoretically the one with the
highest version. (Not true in this case, though -- copland is 0.7.0,
copland-webrick is 0.1.0 -- it looks more like the gems are sorted
alphabetically). Then, it returns that gem, which is in this case
In this case, copland-webrick has a dependency on copland (>= 0.7.0), so
the correct copland gem gets loaded eventually anyway. But it took me a
while to understand why copland-webrick was being loaded everytime I
Hope that is clear enough for someone to see if it is happening in 0.8...
jgb3 at email.byu.edu
"I use octal until I get to 8, and then I switch to decimal."
More information about the Rubygems-developers