Merge pull request #3746 from alyssais/development_tools_bottle

Don't suggest install from bottle if not available
This commit is contained in:
Mike McQuaid 2018-01-29 17:35:52 +00:00 committed by GitHub
commit fdd3aa3000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 # if the user passes any flags/environment that would case a bottle-only
# installation on a system without build tools to fail # installation on a system without build tools to fail
class BuildFlagsError < RuntimeError class BuildFlagsError < RuntimeError
def initialize(flags) def initialize(flags, bottled: true)
if flags.length > 1 if flags.length > 1
flag_text = "flags" flag_text = "flags"
require_text = "require" require_text = "require"
@ -467,13 +467,18 @@ class BuildFlagsError < RuntimeError
require_text = "requires" require_text = "requires"
end end
super <<~EOS message = <<~EOS.chomp!
The following #{flag_text}: The following #{flag_text}:
#{flags.join(", ")} #{flags.join(", ")}
#{require_text} building tools, but none are installed. #{require_text} building tools, but none are installed.
#{DevelopmentTools.installation_instructions} #{DevelopmentTools.installation_instructions}
EOS
message << <<~EOS.chomp! if bottled
Alternatively, remove the #{flag_text} to attempt bottle installation. Alternatively, remove the #{flag_text} to attempt bottle installation.
EOS EOS
super message
end end
end end

View File

@ -70,8 +70,10 @@ class FormulaInstaller
# can proceed. Only invoked when the user has no developer tools. # can proceed. Only invoked when the user has no developer tools.
def self.prevent_build_flags def self.prevent_build_flags
build_flags = ARGV.collect_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 end
def build_bottle? def build_bottle?