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

Jim Weirich jim at weirichhouse.org
Thu Apr 1 19:14:24 EST 2004

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?

You will get a runtime error from the gem code.  The installed gems are 
mutually incompatible.  You will probably need to get a new version of B 
that can use log4r-1.0.6 or better.

An even more insidious problem:  Suppose you have installed two versions 
of log4r, say version 1.1 and 1.2.  Gem A is loaded first and will use 
any version of log4r, so the latest version (1.2) is loaded.   Later you 
load Gem B which requires <= 1.1.  Boom!  Conflict!  Even though A and B 
are not strictly incompatible, the order of loading will cause a problem.

There are algorithms that resolve this.  Unfortunately they need to know 
the complete dependency graph to calculate the proper versions.  Our 
dependencies are discovered as the program executes, making it hard to 
figure this out until it is too late.

I'm not sure how to address this.  I think for now, we need to make sure 
that the user has enough information to resolve the problem until will 
learn how to automate a solution.

-- Jim Weirich    jim at weirichhouse.org     http://onestepback.org
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

More information about the Rubygems-developers mailing list