b8524a
From b95b9942361104dc5b7fd08eb4970f893d8c1a54 Mon Sep 17 00:00:00 2001
b8524a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
b8524a
Date: Wed, 13 Feb 2013 13:12:30 +0100
b8524a
Subject: [PATCH 1/3] Remove duplicated check.
b8524a
b8524a
The loaded specifications are rejected already in #gather_dependencies,
b8524a
so this condition cannot trigger.
b8524a
---
b8524a
 lib/rubygems/dependency_installer.rb | 3 ---
b8524a
 1 file changed, 3 deletions(-)
b8524a
b8524a
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
b8524a
index d811f62..dffa8df 100644
b8524a
--- a/lib/rubygems/dependency_installer.rb
b8524a
+++ b/lib/rubygems/dependency_installer.rb
b8524a
@@ -337,9 +337,6 @@ class Gem::DependencyInstaller
b8524a
 
b8524a
     last = @gems_to_install.size - 1
b8524a
     @gems_to_install.each_with_index do |spec, index|
b8524a
-      # REFACTOR more current spec set hardcoding, should be abstracted?
b8524a
-      next if Gem::Specification.include?(spec) and index != last
b8524a
-
b8524a
       # TODO: make this sorta_verbose so other users can benefit from it
b8524a
       say "Installing gem #{spec.full_name}" if Gem.configuration.really_verbose
b8524a
 
b8524a
-- 
b8524a
1.8.1.2
b8524a
b8524a
b8524a
From 2fa9087b1986db6c7945c0f997fed2bfff5ce06a Mon Sep 17 00:00:00 2001
b8524a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
b8524a
Date: Wed, 13 Feb 2013 15:47:47 +0100
b8524a
Subject: [PATCH 2/3] Do not modify global Specification.dirs during
b8524a
 installation.
b8524a
b8524a
While gems are installed into --install-dir just fine even without
b8524a
modifications of Specification.dirs, change in it makes inaccessible
b8524a
gems already present on the system.
b8524a
---
b8524a
 lib/rubygems/dependency_installer.rb | 15 ++++++---------
b8524a
 1 file changed, 6 insertions(+), 9 deletions(-)
b8524a
b8524a
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
b8524a
index dffa8df..841f26a 100644
b8524a
--- a/lib/rubygems/dependency_installer.rb
b8524a
+++ b/lib/rubygems/dependency_installer.rb
b8524a
@@ -57,16 +57,14 @@ class Gem::DependencyInstaller
b8524a
   # :build_args:: See Gem::Installer::new
b8524a
 
b8524a
   def initialize(options = {})
b8524a
-    @install_dir = options[:install_dir] || Gem.dir
b8524a
 
b8524a
     if options[:install_dir] then
b8524a
-      # HACK shouldn't change the global settings, needed for -i behavior
b8524a
-      # maybe move to the install command?  See also github #442
b8524a
-      Gem::Specification.dirs = @install_dir
b8524a
+      Gem.ensure_gem_subdirectories options[:install_dir]
b8524a
     end
b8524a
 
b8524a
     options = DEFAULT_OPTIONS.merge options
b8524a
 
b8524a
+    @install_dir         = options[:install_dir]
b8524a
     @bin_dir             = options[:bin_dir]
b8524a
     @dev_shallow         = options[:dev_shallow]
b8524a
     @development         = options[:development]
b8524a
@@ -91,7 +88,7 @@ class Gem::DependencyInstaller
b8524a
     @installed_gems = []
b8524a
     @toplevel_specs = nil
b8524a
 
b8524a
-    @cache_dir = options[:cache_dir] || @install_dir
b8524a
+    @cache_dir = options[:cache_dir] || @install_dir || Gem.dir
b8524a
 
b8524a
     # Set with any errors that SpecFetcher finds while search through
b8524a
     # gemspecs for a dep
b8524a
@@ -201,7 +199,7 @@ class Gem::DependencyInstaller
b8524a
     # that this isn't dependent only on the currently installed gems
b8524a
     dependency_list.specs.reject! { |spec|
b8524a
       not keep_names.include?(spec.full_name) and
b8524a
-      Gem::Specification.include?(spec)
b8524a
+      (!@install_dir && Gem::Specification.include?(spec))
b8524a
     }
b8524a
 
b8524a
     unless dependency_list.ok? or @ignore_dependencies or @force then
b8524a
@@ -253,7 +251,7 @@ class Gem::DependencyInstaller
b8524a
           to_do.push t.spec
b8524a
         end
b8524a
 
b8524a
-        results.remove_installed! dep
b8524a
+        results.remove_installed! dep unless @install_dir
b8524a
 
b8524a
         @available << results
b8524a
         results.inject_into_list dependency_list
b8524a
@@ -367,7 +365,7 @@ class Gem::DependencyInstaller
b8524a
                                 :force               => @force,
b8524a
                                 :format_executable   => @format_executable,
b8524a
                                 :ignore_dependencies => @ignore_dependencies,
b8524a
-                                :install_dir         => @install_dir,
b8524a
+                                :install_dir         => (@install_dir || Gem.dir),
b8524a
                                 :security_policy     => @security_policy,
b8524a
                                 :user_install        => @user_install,
b8524a
                                 :wrappers            => @wrappers,
b8524a
-- 
b8524a
1.8.1.2
b8524a
b8524a
b8524a
From d473204ce920702dd87257db49355929f31530d4 Mon Sep 17 00:00:00 2001
b8524a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
b8524a
Date: Fri, 15 Feb 2013 17:02:44 +0100
b8524a
Subject: [PATCH 3/3] Default to Gem.dir as late as possible.
b8524a
b8524a
---
b8524a
 lib/rubygems/dependency_installer.rb | 2 +-
b8524a
 lib/rubygems/installer.rb            | 4 ++--
b8524a
 2 files changed, 3 insertions(+), 3 deletions(-)
b8524a
b8524a
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
b8524a
index 841f26a..abcfa0f 100644
b8524a
--- a/lib/rubygems/dependency_installer.rb
b8524a
+++ b/lib/rubygems/dependency_installer.rb
b8524a
@@ -365,7 +365,7 @@ class Gem::DependencyInstaller
b8524a
                                 :force               => @force,
b8524a
                                 :format_executable   => @format_executable,
b8524a
                                 :ignore_dependencies => @ignore_dependencies,
b8524a
-                                :install_dir         => (@install_dir || Gem.dir),
b8524a
+                                :install_dir         => @install_dir,
b8524a
                                 :security_policy     => @security_policy,
b8524a
                                 :user_install        => @user_install,
b8524a
                                 :wrappers            => @wrappers,
b8524a
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
b8524a
index 780a88b..6543130 100644
b8524a
--- a/lib/rubygems/installer.rb
b8524a
+++ b/lib/rubygems/installer.rb
b8524a
@@ -547,13 +547,13 @@ class Gem::Installer
b8524a
       :bin_dir      => nil,
b8524a
       :env_shebang  => false,
b8524a
       :force        => false,
b8524a
-      :install_dir  => Gem.dir,
b8524a
       :only_install_dir => false
b8524a
     }.merge options
b8524a
 
b8524a
     @env_shebang         = options[:env_shebang]
b8524a
     @force               = options[:force]
b8524a
-    @gem_home            = options[:install_dir]
b8524a
+    @install_dir         = options[:install_dir]
b8524a
+    @gem_home            = options[:install_dir] || Gem.dir
b8524a
     @ignore_dependencies = options[:ignore_dependencies]
b8524a
     @format_executable   = options[:format_executable]
b8524a
     @security_policy     = options[:security_policy]
b8524a
-- 
b8524a
1.8.1.2
b8524a