[Rubygems-developers] Gem autoloading problems
avatar at spellboundnet.com
Wed Apr 16 22:05:01 EDT 2008
So, we were messing around with Passenger for rails recently, and ran into
some behavior that I think needs to be addressed, but I'm not sure how.
Gems, I think as of 1.0, automatically activates a gem's dependencies based on
what its spec says. However, the gem itself has no control over this. This
makes life really hard on systems that need specific handling. In the case of
Passenger, the rails gem is loaded based on the version requested, and more
than one can be loaded (the process forks before rails gets loaded, allowing
multiple versions to be in memory and accessible). However, if the gemspec
has rails in it, activating passenger means that rails automatically gets
activated, and so any further rails activation with a different version
fails. However, the gemspec is entirely correct in that it needs
_some_version of rails, but it really needs to do the activating of the
The first question I have is, what mechanism can be made available to avert
activating a dependent gem until the gem actually needs it?
The next, bigger question IMO is, what should be the default? I can think of
code paths where loading by default would make it really difficult for people
needing deferred loading, but I may be overestimating the scope.
So what do you guys think? I can help to write up the code, but I wanted input
on what to write. :)
More information about the Rubygems-developers