From 8ce0824c39cc35e179ce43678b3f8bb3f798abc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 16 Dec 2019 18:27:37 +0100 Subject: Fix another silent rubygems issue We might be shelling out to rubygems in a `bundle exec` context. In the case where we don't shell out to the `gem` binstub directly, the previous trick wouldn't work. Instead, reset the rubygems ui right after `bundler/setup`, so that if we end up shelling out to rubygems, it will use its default shell (non-silent). The best place to fix this would probably be right inside the `gem` script, but even if we fix it there, we'll need workarounds for previous rubygems versions inside `bundler` so I think this is good for now. --- lib/bundler/cli/exec.rb | 15 +++------------ lib/bundler/setup.rb | 5 +++++ 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index 2bace6e77d..0a1edbdbbd 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -25,12 +25,12 @@ module Bundler SharedHelpers.set_bundle_environment if bin_path = Bundler.which(cmd) if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path) - return with_verbose_rubygems { kernel_load(bin_path, *args) } + return kernel_load(bin_path, *args) end - with_verbose_rubygems { kernel_exec(bin_path, *args) } + kernel_exec(bin_path, *args) else # exec using the given command - with_verbose_rubygems { kernel_exec(cmd, *args) } + kernel_exec(cmd, *args) end end @@ -89,14 +89,5 @@ module Bundler 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/lib/bundler/setup.rb b/lib/bundler/setup.rb index 70a0968f4b..27911dc1ad 100644 --- a/lib/bundler/setup.rb +++ b/lib/bundler/setup.rb @@ -19,4 +19,9 @@ if Bundler::SharedHelpers.in_bundle? else Bundler.ui.silence { Bundler.setup } end + + # We might be in the middle of shelling out to rubygems + # (RUBYOPT=-rbundler/setup), so we need to give rubygems the opportunity of + # not being silent. + Gem::DefaultUserInteraction.ui = nil end -- cgit v1.2.1