From 35f2254dfc09c367070763076a1274b50b3a10cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 25 Jul 2021 13:03:09 +0200 Subject: [PATCH] The `--quiet` should still display warnings The is the previous intentional behaviour until https://github.com/rubygems/bundler/commit/ca0676cb1c638e0b9747ea8c18f28adf82cc01de. In my opinion, that previous behaviour was better and should be restored, because we want our users to always see warnings and fix them. And the original issue that motivated the change is fixable by other means, namely through `BUNDLE_SILENCE_ROOT_WARNING`, or through `BUNDLE_SILENCE_DEPRECATIONS` in general. Finally, the --quiet option is still documented as "only print errors and warnings". So this PR essentially reverts https://github.com/rubygems/bundler/commit/ca0676cb1c638e0b9747ea8c18f28adf82cc01de for the above reasons. --- bundler/lib/bundler/cli/cache.rb | 2 +- bundler/lib/bundler/cli/doctor.rb | 2 +- bundler/lib/bundler/cli/install.rb | 2 +- bundler/lib/bundler/cli/update.rb | 2 +- bundler/spec/commands/install_spec.rb | 18 ++++++++++++++++-- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/bundler/lib/bundler/cli/cache.rb b/bundler/lib/bundler/cli/cache.rb index 9cd6133879ac..c8698ed7e38e 100644 --- a/bundler/lib/bundler/cli/cache.rb +++ b/bundler/lib/bundler/cli/cache.rb @@ -9,7 +9,7 @@ def initialize(options) end def run - Bundler.ui.level = "error" if options[:quiet] + Bundler.ui.level = "warn" if options[:quiet] Bundler.settings.set_command_option_if_given :path, options[:path] Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"] diff --git a/bundler/lib/bundler/cli/doctor.rb b/bundler/lib/bundler/cli/doctor.rb index 959b1b5e049f..c28997bc7ddb 100644 --- a/bundler/lib/bundler/cli/doctor.rb +++ b/bundler/lib/bundler/cli/doctor.rb @@ -61,7 +61,7 @@ def check! end def run - Bundler.ui.level = "error" if options[:quiet] + Bundler.ui.level = "warn" if options[:quiet] Bundler.settings.validate! check! diff --git a/bundler/lib/bundler/cli/install.rb b/bundler/lib/bundler/cli/install.rb index 5e39e2a36d6d..c86d8d31e3fa 100644 --- a/bundler/lib/bundler/cli/install.rb +++ b/bundler/lib/bundler/cli/install.rb @@ -8,7 +8,7 @@ def initialize(options) end def run - Bundler.ui.level = "error" if options[:quiet] + Bundler.ui.level = "warn" if options[:quiet] warn_if_root diff --git a/bundler/lib/bundler/cli/update.rb b/bundler/lib/bundler/cli/update.rb index cf6a5b26d3e2..1adcaef67cfb 100644 --- a/bundler/lib/bundler/cli/update.rb +++ b/bundler/lib/bundler/cli/update.rb @@ -9,7 +9,7 @@ def initialize(options, gems) end def run - Bundler.ui.level = "error" if options[:quiet] + Bundler.ui.level = "warn" if options[:quiet] Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins? diff --git a/bundler/spec/commands/install_spec.rb b/bundler/spec/commands/install_spec.rb index 478ee9c38a37..789fd9b5c0c0 100644 --- a/bundler/spec/commands/install_spec.rb +++ b/bundler/spec/commands/install_spec.rb @@ -585,7 +585,20 @@ end describe "when requesting a quiet install via --quiet" do - it "should be quiet" do + it "should be quiet if there are no warnings" do + bundle "config set force_ruby_platform true" + + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem 'rack' + G + + bundle :install, :quiet => true + expect(out).to be_empty + expect(err).to be_empty + end + + it "should still display warnings and errors" do bundle "config set force_ruby_platform true" create_file("install_with_warning.rb", <<~RUBY) @@ -611,8 +624,9 @@ def run G bundle :install, :quiet => true, :raise_on_error => false, :env => { "RUBYOPT" => "-r#{bundled_app("install_with_warning.rb")}" } + expect(out).to be_empty expect(err).to include("Could not find gem 'non-existing-gem'") - expect(err).not_to include("BOOOOO") + expect(err).to include("BOOOOO") end end