Skip to content

Commit

Permalink
The --quiet should still display warnings
Browse files Browse the repository at this point in the history
The is the previous intentional behaviour until
rubygems/bundler@ca0676c.

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
rubygems/bundler@ca0676c
for the above reasons.
  • Loading branch information
deivid-rodriguez committed Jul 25, 2021
1 parent cce4f86 commit 35f2254
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bundler/lib/bundler/cli/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/cli/doctor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/cli/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/cli/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
18 changes: 16 additions & 2 deletions bundler/spec/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 35f2254

Please sign in to comment.