Don't suggest install from bottle if not available

It only makes sense to tell a user to try installing from a bottle if
there are bottles available for them to install for all the formulae
they specified.
This commit is contained in:
Alyssa Ross 2018-01-28 22:44:03 +00:00
parent 9f4b4a1699
commit a9dc02a586
No known key found for this signature in database
GPG Key ID: 6CF064D149E3ABDB
2 changed files with 10 additions and 3 deletions

View File

@ -458,7 +458,7 @@ end
# if the user passes any flags/environment that would case a bottle-only
# installation on a system without build tools to fail
class BuildFlagsError < RuntimeError
def initialize(flags)
def initialize(flags, bottled: true)
if flags.length > 1
flag_text = "flags"
require_text = "require"
@ -467,13 +467,18 @@ class BuildFlagsError < RuntimeError
require_text = "requires"
end
super <<~EOS
message = <<~EOS.chomp!
The following #{flag_text}:
#{flags.join(", ")}
#{require_text} building tools, but none are installed.
#{DevelopmentTools.installation_instructions}
EOS
message << <<~EOS.chomp! if bottled
Alternatively, remove the #{flag_text} to attempt bottle installation.
EOS
super message
end
end

View File

@ -70,8 +70,10 @@ class FormulaInstaller
# can proceed. Only invoked when the user has no developer tools.
def self.prevent_build_flags
build_flags = ARGV.collect_build_flags
return if build_flags.empty?
raise BuildFlagsError, build_flags unless build_flags.empty?
all_bottled = ARGV.formulae.all?(&:bottled?)
raise BuildFlagsError.new(build_flags, bottled: all_bottled)
end
def build_bottle?