2b6417
From 745899dec8f28d50a37dc03a96bbea972caaef58 Mon Sep 17 00:00:00 2001
2b6417
From: SHIBATA Hiroshi <hsbt@ruby-lang.org>
2b6417
Date: Tue, 19 Feb 2019 22:41:56 +0900
2b6417
Subject: [PATCH] Use ENV["BUNDLE_GEM"] instead of gem command provided by
2b6417
 system ruby.
2b6417
2b6417
  It break the examples of bundler. Because some examples detect the
2b6417
  different version of system ruby than test target version like trunk.
2b6417
---
2b6417
 lib/bundler/gem_helper.rb            |  8 ++++++--
2b6417
 spec/bundler/commands/clean_spec.rb  | 14 +++++++++-----
2b6417
 spec/bundler/support/rubygems_ext.rb |  7 ++-----
2b6417
 3 files changed, 17 insertions(+), 12 deletions(-)
2b6417
2b6417
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
2b6417
index e7673cba88..c54259b5b6 100644
2b6417
--- a/lib/bundler/gem_helper.rb
2b6417
+++ b/lib/bundler/gem_helper.rb
2b6417
@@ -74,7 +74,8 @@ def install
2b6417
 
2b6417
     def build_gem
2b6417
       file_name = nil
2b6417
-      sh("gem build -V '#{spec_path}'") do
2b6417
+      gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem"
2b6417
+      sh("#{gem} build -V #{spec_path}") do
2b6417
         file_name = File.basename(built_gem_path)
2b6417
         SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) }
2b6417
         FileUtils.mv(built_gem_path, "pkg")
2b6417
@@ -85,7 +86,10 @@ def build_gem
2b6417
 
2b6417
     def install_gem(built_gem_path = nil, local = false)
2b6417
       built_gem_path ||= build_gem
2b6417
-      out, _ = sh_with_code("gem install '#{built_gem_path}'#{" --local" if local}")
2b6417
+      gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem"
2b6417
+      cmd = "#{gem} install #{built_gem_path}"
2b6417
+      cmd = "#{cmd} --local" if local
2b6417
+      out, _ = sh_with_code(cmd)
2b6417
       raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/]
2b6417
       Bundler.ui.confirm "#{name} (#{version}) installed."
2b6417
     end
2b6417
diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb
2b6417
index 37cbeeb4e7..74a5b86ec1 100644
2b6417
--- a/spec/bundler/commands/clean_spec.rb
2b6417
+++ b/spec/bundler/commands/clean_spec.rb
2b6417
@@ -339,7 +339,8 @@ def should_not_have_gems(*gems)
2b6417
       gem "rack"
2b6417
     G
2b6417
 
2b6417
-    sys_exec! "gem list"
2b6417
+    gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
2b6417
+    sys_exec! "#{gem} list"
2b6417
     expect(out).to include("rack (1.0.0)").and include("thin (1.0)")
2b6417
   end
2b6417
 
2b6417
@@ -461,8 +462,9 @@ def should_not_have_gems(*gems)
2b6417
     end
2b6417
     bundle! :update, :all => bundle_update_requires_all?
2b6417
 
2b6417
-    sys_exec! "gem list"
2b6417
-    expect(out).to include("foo (1.0.1, 1.0)")
2b6417
+    gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
2b6417
+    sys_exec! "#{gem} list"
2b6417
+  expect(out).to include("foo (1.0.1, 1.0)")
2b6417
   end
2b6417
 
2b6417
   it "cleans system gems when --force is used" do
2b6417
@@ -485,7 +487,8 @@ def should_not_have_gems(*gems)
2b6417
     bundle "clean --force"
2b6417
 
2b6417
     expect(out).to include("Removing foo (1.0)")
2b6417
-    sys_exec "gem list"
2b6417
+    gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
2b6417
+    sys_exec "#{gem} list"
2b6417
     expect(out).not_to include("foo (1.0)")
2b6417
     expect(out).to include("rack (1.0.0)")
2b6417
   end
2b6417
@@ -519,7 +522,8 @@ def should_not_have_gems(*gems)
2b6417
       expect(out).to include(system_gem_path.to_s)
2b6417
       expect(out).to include("grant write permissions")
2b6417
 
2b6417
-      sys_exec "gem list"
2b6417
+      gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
2b6417
+      sys_exec "#{gem} list"
2b6417
       expect(out).to include("foo (1.0)")
2b6417
       expect(out).to include("rack (1.0.0)")
2b6417
     end
2b6417
diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb
2b6417
index c18f7650fc..408d715ecf 100644
2b6417
--- a/spec/bundler/support/rubygems_ext.rb
2b6417
+++ b/spec/bundler/support/rubygems_ext.rb
2b6417
@@ -59,11 +59,8 @@ def self.install_gems(gems)
2b6417
       no_reqs.map!(&:first)
2b6417
       reqs.map! {|name, req| "'#{name}:#{req}'" }
2b6417
       deps = reqs.concat(no_reqs).join(" ")
2b6417
-      cmd = if Gem::VERSION < "2.0.0"
2b6417
-        "gem install #{deps} --no-rdoc --no-ri --conservative"
2b6417
-      else
2b6417
-        "gem install #{deps} --no-document --conservative"
2b6417
-      end
2b6417
+      gem = Spec::Path.ruby_core? ? ENV["BUNDLE_GEM"] : "#{Gem.ruby} -S gem"
2b6417
+      cmd = "#{gem} install #{deps} --no-document --conservative"
2b6417
       puts cmd
2b6417
       system(cmd) || raise("Installing gems #{deps} for the tests to use failed!")
2b6417
     end
2b6417
-- 
2b6417
2.31.1
2b6417