diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb index 9cd6133879..c8698ed7e3 100644 --- a/lib/bundler/cli/cache.rb +++ b/lib/bundler/cli/cache.rb @@ -9,7 +9,7 @@ module Bundler 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/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb index 959b1b5e04..c28997bc7d 100644 --- a/lib/bundler/cli/doctor.rb +++ b/lib/bundler/cli/doctor.rb @@ -61,7 +61,7 @@ module Bundler end def run - Bundler.ui.level = "error" if options[:quiet] + Bundler.ui.level = "warn" if options[:quiet] Bundler.settings.validate! check! diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 5e39e2a36d..c86d8d31e3 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -8,7 +8,7 @@ module Bundler end def run - Bundler.ui.level = "error" if options[:quiet] + Bundler.ui.level = "warn" if options[:quiet] warn_if_root diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index cf6a5b26d3..1adcaef67c 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -9,7 +9,7 @@ module Bundler 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/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 478ee9c38a..789fd9b5c0 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -585,7 +585,20 @@ RSpec.describe "bundle install with gem sources" do 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 @@ RSpec.describe "bundle install with gem sources" do 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