From 320ac535f15169d19e1d393095eed586d6b1f8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 18 Nov 2019 12:48:10 +0100 Subject: [PATCH] Fix shelling out to rubygems being silent --- lib/bundler/cli/exec.rb | 15 ++++++++++++--- spec/commands/exec_spec.rb | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index 0a1edbdbbdf..2bace6e77df 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -25,12 +25,12 @@ def run SharedHelpers.set_bundle_environment if bin_path = Bundler.which(cmd) if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path) - return kernel_load(bin_path, *args) + return with_verbose_rubygems { kernel_load(bin_path, *args) } end - kernel_exec(bin_path, *args) + with_verbose_rubygems { kernel_exec(bin_path, *args) } else # exec using the given command - kernel_exec(cmd, *args) + with_verbose_rubygems { kernel_exec(cmd, *args) } end end @@ -89,5 +89,14 @@ def ruby_shebang?(file) first_line = File.open(file, "rb") {|f| f.read(possibilities.map(&:size).max) } possibilities.any? {|shebang| first_line.start_with?(shebang) } end + + def with_verbose_rubygems + old_ui = Gem::DefaultUserInteraction.ui + Gem::DefaultUserInteraction.ui = nil + + yield + ensure + Gem::DefaultUserInteraction.ui = old_ui + end end end diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 7ae504d3608..d2e85a289bf 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -55,6 +55,12 @@ expect(out).to eq("hi") end + it "works when exec'ing to rubygems" do + install_gemfile 'gem "rack"' + bundle "exec gem --version" + expect(out).to eq(Gem::VERSION) + end + it "respects custom process title when loading through ruby" do script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~'RUBY' Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15")