[Rubygems-developers] Patch for 0.9.0

Hugh Sasse hgs at dmu.ac.uk
Thu Sep 14 13:53:47 EDT 2006


I always run into problems updating FXRuby because of its dependencies
on Fox, and I don't really expect Rubygems to be able to cope with 
that level of complexity [yet].  But at present there's no way to 
skip a gem when presented with a list, and then carry on.  This patch
fixes that. It seems to be working for me.

<quote>
 25. fxruby 1.2.3 (mswin32)
 26. fxruby 1.2.2 (ruby)
 27. fxruby 1.2.2 (mswin32)
 28. fxruby 1.2.1 (mswin32)
 29. fxruby 1.2.1 (ruby)
 30. Skip this gem
 31. Cancel installation
> 30
Installation of fxruby skipped.
Attempting remote update of needle
Successfully installed needle-1.3.0
<quote>

I hope it doesn't break anything.

        Hugh

--- rubygems-0.9.0/lib/rubygems/remote_installer.rb.orig	2006-06-07 04:39:54.000000000 +0100
+++ rubygems-0.9.0/lib/rubygems/remote_installer.rb	2006-09-14 18:43:09.989058000 +0100
@@ -13,6 +13,7 @@
   class RemoteSourceException < Gem::Exception; end
   class GemNotFoundException < Gem::Exception; end
   class RemoteInstallationCancelled < Gem::Exception; end
+  class RemoteInstallationSkipped < Gem::Exception; end
 
   ####################################################################
   # RemoteSourceFetcher handles the details of fetching gems and gem
@@ -434,14 +435,18 @@
       end
       installed_gems = []
       caches = source_index_hash
-      spec, source = find_gem_to_install(gem_name, version_requirement, caches)
-      dependencies = find_dependencies_not_installed(spec.dependencies)
-      installed_gems << install_dependencies(dependencies, force, install_dir)
-      cache_dir = File.join(install_dir, "cache")
-      destination_file = File.join(cache_dir, spec.full_name + ".gem")
-      download_gem(destination_file, source, spec)
-      installer = new_installer(destination_file)
-      installed_gems.unshift installer.install(force, install_dir, install_stub)
+      begin
+        spec, source = find_gem_to_install(gem_name, version_requirement, caches)
+        dependencies = find_dependencies_not_installed(spec.dependencies)
+        installed_gems << install_dependencies(dependencies, force, install_dir)
+        cache_dir = File.join(install_dir, "cache")
+        destination_file = File.join(cache_dir, spec.full_name + ".gem")
+        download_gem(destination_file, source, spec)
+        installer = new_installer(destination_file)
+        installed_gems.unshift installer.install(force, install_dir, install_stub)
+      rescue RemoteInstallationSkipped => e
+        puts e.message
+      end
       installed_gems.flatten
     end
 
@@ -512,6 +517,7 @@
 	"#{item[0].name} #{item[0].version} (#{item[0].platform.to_s})"
       }
 
+      list << "Skip this gem"
       list << "Cancel installation"
 
       string, index = choose_from_list(
@@ -522,6 +528,10 @@
         raise RemoteInstallationCancelled, "Installation of #{gem_name} cancelled."
       end
 
+      if index == (list.size - 2) then
+        raise RemoteInstallationSkipped, "Installation of #{gem_name} skipped."
+      end
+
       specs_n_sources[index]
     end
 



More information about the Rubygems-developers mailing list