[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
Fri Dec 18 04:57:46 EST 2009


Bugs item #27588, was opened at 2009-12-18 04: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: None
Priority: 3
Submitted By: Daniel Parker (dcparker)
Assigned to: Nobody (None)
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


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

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