[Rubygems-developers] Corner case: can gems handle this?

Mauricio Fernández batsman.geo at yahoo.com
Fri Apr 2 02:03:20 EST 2004


On Fri, Apr 02, 2004 at 08:42:57AM +1000, Gavin Sinclair wrote:
> If I create a gem "A", which depends on libs "B" and "C", and if "B"
> depends on "log4r < 1.0" and "C" depends on "log4r > 1.0.5", what
> happens?
> 
> I know the installation is fine, but what happens at runtime?

IIRC this is what will happen (assuming B is required before C):

A does require_gems "B"
B does require_gems "log4r", "< 1.0"   some log4r < 1.0 is loaded
A does require_gems "C"
C does require_gems "log4r", "> 1.0.5"

2 possibilities now:
* there's a matching version: its path + 'autorequire path' is
  added to $:, require 'log4r' is performed (non-op since log4r is already
  in $"); require_gems returns true, the rest of C's code believes 
  log4r > 1.0.5 is loaded. Subtle breakage.
* no matching version (if the user removed the 2nd version of log4r;
  this is possible since IIRC rubygems doesn't consider
  reverse-dependencies when removing stuff): require_gems fails right
  there

Another border case:

A depends on B and C. B depends on "log4r < 2.0" and C depends on
"log4r < 1.2"; log4r 1.0 and 1.5 are installed.

At load time, we'd like to reach the following state:
loaded: A, B, C, log4r 1.0

This is what happens with the current implementation:

A does require_gems "B"
B does require_gems "log4r", "< 2.0"    log4r 1.5 is loaded
A does require_gems "C"
C does require_gems "log4r", "< 1.2"  
   log4r 1.0 is seemingly loaded, but it's actually still 1.5 (like the
   scenario above)

This is what would happen if the problem above was corrected:
A does require_gems "B"
B does require_gems "log4r", "< 2.0"    log4r 1.5 is loaded
A does require_gems "C"
C does require_gems "log4r", "< 1.2"  
  require_gems fails because 1.5 was installed before and it's not
  possible to unrequire(). The system fails to reach the desired state
  where log4r 1.0 is installed.

-- 
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

I am NOT a kludge!  I am a computer!
	-- tts


More information about the Rubygems-developers mailing list