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