[Rubygems-developers] [ rubygems-Bugs-27588 ] Activating a dependency raises error even though a satisfactory version is already activated.

noreply at rubyforge.org noreply at rubyforge.org
Sat Nov 13 08:51:49 EST 2010


Bugs item #27588, was opened at 2009-12-18 01:57
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=27588&group_id=126

Category: #gem and #require methods
Group: None
Status: Open
>Resolution: Out of Date
Priority: 3
Submitted By: Daniel Parker (dcparker)
Assigned to: Ryan Davis (zenspider)
Summary: Activating a dependency raises error even though a satisfactory version is already activated.

Initial Comment:
I have loaded a gem "A" that loaded version 0.9.13 of gem "B", and then continued to load gem "C" that needed version "~> 0.9.12" of gem "B". Under normal conditions, version 0.9.13 should suit just fine if I'm looking for "~> 0.9.12".

But in this case, since:
  (1) version 0.9.13 is *already loaded*, and
  (2) I have since changed my Gem path in such a way that 0.9.13 is not able to be found in the new Gem path,
 -> it fails and raises an error saying that it can't activate.

This happens because in rubygems.rb, line 268:

unless matches.any? { |spec| spec.version == existing_spec.version } then

This should look at the existing spec and test whether it passes the version-requirements. However, the way it is doing it depends on the already-loaded spec to be able to be found again in the most recent search. This fails if the Gem paths have changed and the already-loaded spec is a version that is no longer able to be found in the new Gem path.

This proposed change to this single line fixes the problem:

rubygems.rb at 268
- unless matches.any? { |spec| spec.version == existing_spec.version } then
+ unless gem.version_requirements.satisfied_by?(existing_spec.version) then


----------------------------------------------------------------------

Comment By: Ryan Davis (zenspider)
Date: 2010-11-12 16:59

Message:
Please respond to Eric's question so I can write a failing test.

----------------------------------------------------------------------

Comment By: Eric Hodel (drbrain)
Date: 2010-02-06 22:02

Message:
Do you have a set of gems that can reproduce this?

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=27588&group_id=126


More information about the Rubygems-developers mailing list