Package: rubygems
Version: 0.9.0-5
Severity: normal
Tags: patch

First, it is nice to have rubygems, thank you.

I think since Debian provides rubygems now, it should patch it to be a
bit smarter about installed debian packages which provide the same
functionality as gems.

Example: 

aptitude install rake rails
gem install mongrel

gem will insist on installing dependencies, including rake. A really
nicely patched up rubygems could autodetect the rake package.

I accept, go on, and force "gem uninstall rake" right afterwards. Now
mongrel doesn't want to start, because it *thinks* there is no rake
available, without even trying.

As a quick and dirty hack, I dropped the attached rubygems.rb in my
$HOME/ruby/lib, added that path to $RUBYLIB, and everything seems to
work just fine. My rubygems.rb wraps the original, and, on
Gem::LoadError, tries to continue nevertheless, which just works if
there are aequivalent files installed by debian packages. If not, it
will fail later with a less descriptive error message.

A second attached version tries to query dpkg to determine if it may
continue or not, but I am not sure this is actually an improvement. 

Now this is a very ugly solution, and I am sure this could be done
better by the rubygems package itself. As a quick fix, you could just
append my file to rubygem's rubygems.rb.

A comprehensive solution would be to have all ruby library packages
install fake geminfo metadata, and rubygems to query that additionally
when resolving dependencies. (Note: I do not want rubygems to
add/remove deb packages, just recognize them!)

Severity set to normal, as the current version of rubygems makes a
mixed Debian-packages + gems system (for libraries) impossible, if any
installed gems depend on installed debs, which is very likely.

regards,
Jürgen Strobel

-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (850, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-zerberos-2
Locale: LANG=C, [EMAIL PROTECTED] (charmap=ISO-8859-15)
-- no debconf information

-- 
 The box said it requires Windows 95 or better so I installed Linux
# -*- ruby -*-

#--
# Copyright 2007 by Jürgen Strobel
# Free to use without any restrictions.
#++

# This wraps rubygems.rb.
# The mission is to patch up Gem.activate, so it doesn't complain
# over non existing gems if an aequivalent debian package is installed.
# If gems are installed, they are still used in preference over debs.
# This is crude and pollutes $stderr. YMMV.


require "/usr/lib/ruby/1.8/rubygems.rb"

module Gem   
  class << self
    alias activate_orig_debian activate
    def activate(gem, autorequire, *version_requirements)
      activate_orig_debian(gem, autorequire, *version_requirements)
    rescue Gem::LoadError => e
      $stderr << "Debug: Gem #{gem} not found, trying to continue\n"
      return true
    end    
  end
end
# -*- ruby -*-

#--
# Copyright 2007 by Jürgen Strobel
# Free to use without any restrictions.
#++

# This wraps rubygems.rb.
# The mission is to patch up Gem.activate, so it doesn't complain
# over non existing gems if an aequivalent debian package is installed.
# If gems are installed, they are still used in preference over debs.
# This is crude and pollutes $stderr. YMMV.


require "/usr/lib/ruby/1.8/rubygems.rb"

module Gem   
  class << self
    alias activate_orig_debian activate
    def activate(gem, autorequire, *version_requirements)
      activate_orig_debian(gem, autorequire, *version_requirements)
    rescue Gem::LoadError => e
      $stderr << "Debug: Gem #{gem} not found, maybe we can continue?\n"
      `dpkg -l "#{gem.name}" 2>/dev/null | grep '^ii'`
      if $?.success?
        $stderr << "Debug: #{gem.name}.deb is installed, trying to continue.\n"
        return true
      end
      f = `dpkg -l "lib#{gem.name}*-ruby*" 2>/dev/null | grep '^ii'`
      if $?.success?
        $stderr << "Debug: #{f.split[1]}.deb is installed, trying to 
continue.\n"
        return true
      end
      raise e
    end
    
  end
end

Attachment: signature.asc
Description: Digital signature

Reply via email to