diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb index b95c42c361..090cb7e2ca 100644 --- a/lib/bundler/retry.rb +++ b/lib/bundler/retry.rb @@ -50,7 +50,7 @@ module Bundler end return true unless name Bundler.ui.info "" unless Bundler.ui.debug? # Add new line in case dots preceded this - Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug? + Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", true end def keep_trying? diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb index 899f3dcb87..16e7cc70b5 100644 --- a/lib/bundler/ui/shell.rb +++ b/lib/bundler/ui/shell.rb @@ -130,7 +130,7 @@ module Bundler def tell_err(message, color = nil, newline = nil) return if @shell.send(:stderr).closed? - newline ||= !message.to_s.match?(/( |\t)\Z/) + newline = !message.to_s.match?(/( |\t)\Z/) if newline.nil? message = word_wrap(message) if newline.is_a?(Hash) && newline[:wrap] color = nil if color && !$stderr.tty? diff --git a/spec/bundler/bundler/retry_spec.rb b/spec/bundler/bundler/retry_spec.rb index b893580d72..ffbc078074 100644 --- a/spec/bundler/bundler/retry_spec.rb +++ b/spec/bundler/bundler/retry_spec.rb @@ -68,7 +68,7 @@ RSpec.describe Bundler::Retry do it "print error message with newlines" do allow(Bundler.ui).to receive(:debug?).and_return(false) expect(Bundler.ui).to receive(:info).with("").twice - expect(Bundler.ui).to receive(:warn).with(failure_message, false) + expect(Bundler.ui).to receive(:warn).with(failure_message, true) expect do Bundler::Retry.new("test", [], 1).attempt do diff --git a/spec/bundler/bundler/ui/shell_spec.rb b/spec/bundler/bundler/ui/shell_spec.rb index 15120a8a41..e1340e5923 100644 --- a/spec/bundler/bundler/ui/shell_spec.rb +++ b/spec/bundler/bundler/ui/shell_spec.rb @@ -21,9 +21,12 @@ RSpec.describe Bundler::UI::Shell do describe "#warn" do before { subject.level = "warn" } - it "prints to stderr" do + it "prints to stderr, implicitly adding a newline" do expect { subject.warn("warning") }.to output("warning\n").to_stderr end + it "can be told not to emit a newline" do + expect { subject.warn("warning", false) }.to output("warning").to_stderr + end end describe "#debug" do