diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 51ad3898fa..00cdf04d7a 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -466,15 +466,17 @@ class BuildFlagsError < RuntimeError require_text = "requires" end + bottle_text = if bottled + <<~EOS + Alternatively, remove the #{flag_text} to attempt bottle installation. + EOS + end + message = <<~EOS The following #{flag_text}: #{flags.join(", ")} #{require_text} building tools, but none are installed. - #{DevelopmentTools.installation_instructions} - EOS - - message << <<~EOS if bottled - Alternatively, remove the #{flag_text} to attempt bottle installation. + #{DevelopmentTools.installation_instructions}#{bottle_text} EOS super message diff --git a/Library/Homebrew/test/exceptions_spec.rb b/Library/Homebrew/test/exceptions_spec.rb index 63bc8410b8..ee0aa4f370 100644 --- a/Library/Homebrew/test/exceptions_spec.rb +++ b/Library/Homebrew/test/exceptions_spec.rb @@ -225,3 +225,9 @@ describe BottleFormulaUnavailableError do its(:to_s) { is_expected.to match(/This bottle does not contain the formula file/) } end + +describe BuildFlagsError do + subject { described_class.new(["-s"]) } + + its(:to_s) { is_expected.to match(/flag:\s+-s\nrequires building tools/) } +end