[Rubygems-developers] PATCH: respect requirements of gems

Chad Fowler chad at chadfowler.com
Wed Apr 21 21:14:32 EDT 2004

On 21/4/2004, at 8:01 PM, Dick Davies wrote:

> Hi, I noticed tonight that if I install copland, it pulls in log4r as 
> I'd expect.
> But if I gem -u log4r, gem chugs away happily and removes the log4r, 
> breaking copland.
> I could think of several ways to fix this, ideally I guess gems should 
> know what requires them,
> but as I don't know enough about the gemspec format yet I think that 
> might be a pig to do.
> The patch below isn't perfect, but it lets you ask a 
> Gem::Specification object what other gems need it.
> I do the check in Uninstaller.remove(), I hope that's the right place.
> It gives output like this:
> 0rasputin at lb:gems$ gem -u log4r
> Attempting to uninstall gem 'log4r'
> gem log4r-1.0.5 is required by the following gems:
> copland-0.3.0
> 0rasputin at lb:gems$
> Output should be one gem per line, but obviously I can't test that yet 
> :)

Hi Dick.

This is definitely something stupid about RubyGems' current behavior.  
I thought of it while driving to work one day, and forgot about it by 
the time I got in to the office. :)

I don't, however, like the idea of gems being responsible for telling 
us which gems depend on them.  I don't think this is too hard a 
problem, though.  We can always do something like (I haven't tried to 
run this yet):

def check_dependent_gems(gem_name, gem_version)
   dependent = []
   Gem::Cache.from_installed_gems.each do { |name, spec|
     spec.dependencies.each do |d|
       if(d.name == name, and d.version == version) then
         dependent << spec

What do you think?


More information about the Rubygems-developers mailing list