Make HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK default

- Remove `HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK` and make the behaviour
  the default. We mostly already do this since we added the need for
  the `--build-from-source` override on macOS. This allows us to
  delete some more code.
- Still fail and require `--build-from-source` when reinstalling or
  upgrading if failing on a formula-specific reason e.g. the CLT is
  not/no longer installed, you're using a non-default prefix.

Fixes #10623
This commit is contained in:
Mike McQuaid 2021-02-17 13:51:53 +00:00
parent fa638d29d8
commit 22e591e531
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
4 changed files with 26 additions and 61 deletions

View File

@ -212,11 +212,6 @@ module Homebrew
description: "If set, do not use Bootsnap to speed up repeated `brew` calls.", description: "If set, do not use Bootsnap to speed up repeated `brew` calls.",
boolean: true, boolean: true,
}, },
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: {
description: "If set, fail on the failure of installation from a bottle rather than " \
"falling back to building from source.",
boolean: true,
},
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: { HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: {
description: "If set, do not check for broken dependents after installing, upgrading or reinstalling " \ description: "If set, do not check for broken dependents after installing, upgrading or reinstalling " \
"formulae.", "formulae.",

View File

@ -94,7 +94,6 @@ class FormulaInstaller
@options = options @options = options
@requirement_messages = [] @requirement_messages = []
@poured_bottle = false @poured_bottle = false
@pour_failed = false
@start_time = nil @start_time = nil
end end
@ -154,8 +153,6 @@ class FormulaInstaller
sig { params(output_warning: T::Boolean).returns(T::Boolean) } sig { params(output_warning: T::Boolean).returns(T::Boolean) }
def pour_bottle?(output_warning: false) def pour_bottle?(output_warning: false)
return false if @pour_failed
return false if !formula.bottle_tag? && !formula.local_bottle_path return false if !formula.bottle_tag? && !formula.local_bottle_path
return true if force_bottle? return true if force_bottle?
return false if build_from_source? || build_bottle? || interactive? return false if build_from_source? || build_bottle? || interactive?
@ -235,8 +232,7 @@ class FormulaInstaller
# homebrew-core and have full bottle coverage. # homebrew-core and have full bottle coverage.
(OS.mac? || ENV["CI"]) && (OS.mac? || ENV["CI"]) &&
!build_from_source? && !build_bottle? && !build_from_source? && !build_bottle? &&
!installed_as_dependency? && formula.tap&.core_tap? && !formula.bottle_unneeded? &&
formula.tap&.core_tap? && !formula.bottle_unneeded? && !formula.any_version_installed? &&
# Integration tests override homebrew-core locations # Integration tests override homebrew-core locations
ENV["HOMEBREW_TEST_TMPDIR"].nil? && ENV["HOMEBREW_TEST_TMPDIR"].nil? &&
!pour_bottle? !pour_bottle?
@ -244,12 +240,19 @@ class FormulaInstaller
formula_message = formula.pour_bottle_check_unsatisfied_reason formula_message = formula.pour_bottle_check_unsatisfied_reason
formula_message[0] = formula_message[0].downcase formula_message[0] = formula_message[0].downcase
"#{formula}: #{formula_message}" <<~EOS
else #{formula}: #{formula_message}
EOS
# don't want to complain about no bottle available if doing an
# upgrade/reinstall/dependency install (but do in the case the bottle
# check fails)
elsif !installed_as_dependency? && !formula.any_version_installed?
<<~EOS <<~EOS
#{formula}: no bottle available! #{formula}: no bottle available!
EOS EOS
end end
if message
message += <<~EOS message += <<~EOS
You can try to install from source with: You can try to install from source with:
brew install --build-from-source #{formula} brew install --build-from-source #{formula}
@ -260,6 +263,7 @@ class FormulaInstaller
EOS EOS
raise CannotInstallFormulaError, message raise CannotInstallFormulaError, message
end end
end
type, reason = DeprecateDisable.deprecate_disable_info formula type, reason = DeprecateDisable.deprecate_disable_info formula
@ -429,7 +433,7 @@ class FormulaInstaller
if pour_bottle? if pour_bottle?
begin begin
pour pour
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception # rubocop:disable Lint/RescueException
# any exceptions must leave us with nothing installed # any exceptions must leave us with nothing installed
ignore_interrupts do ignore_interrupts do
begin begin
@ -442,17 +446,7 @@ class FormulaInstaller
end end
formula.rack.rmdir_if_possible formula.rack.rmdir_if_possible
end end
raise if Homebrew::EnvConfig.developer? || raise
Homebrew::EnvConfig.no_bottle_source_fallback? ||
force_bottle? ||
e.is_a?(Interrupt)
@pour_failed = true
onoe e.message
opoo "Bottle installation failed: building from source."
raise UnbottledError, [formula] unless DevelopmentTools.installed?
compute_and_install_dependencies unless ignore_deps?
else else
@poured_bottle = true @poured_bottle = true
end end
@ -513,7 +507,7 @@ class FormulaInstaller
$stderr.puts "Please report this issue to the #{formula.tap} tap (not Homebrew/brew or Homebrew/core)!" $stderr.puts "Please report this issue to the #{formula.tap} tap (not Homebrew/brew or Homebrew/core)!"
false false
else # rubocop:disable Layout/ElseAlignment else
f.linked_keg.exist? && f.opt_prefix.exist? f.linked_keg.exist? && f.opt_prefix.exist?
end end
@ -1123,25 +1117,10 @@ class FormulaInstaller
return if only_deps? return if only_deps?
if pour_bottle?(output_warning: true) unless pour_bottle?(output_warning: true)
begin
downloader.fetch
rescue Exception => e # rubocop:disable Lint/RescueException
raise if Homebrew::EnvConfig.developer? ||
Homebrew::EnvConfig.no_bottle_source_fallback? ||
force_bottle? ||
e.is_a?(Interrupt)
@pour_failed = true
onoe e.message
opoo "Bottle installation failed: building from source."
fetch_dependencies
end
end
return if pour_bottle?
formula.fetch_patches formula.fetch_patches
formula.resources.each(&:fetch) formula.resources.each(&:fetch)
end
downloader.fetch downloader.fetch
end end

View File

@ -1852,9 +1852,6 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
- `HOMEBREW_NO_BOOTSNAP` - `HOMEBREW_NO_BOOTSNAP`
<br>If set, do not use Bootsnap to speed up repeated `brew` calls. <br>If set, do not use Bootsnap to speed up repeated `brew` calls.
- `HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK`
<br>If set, fail on the failure of installation from a bottle rather than falling back to building from source.
- `HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK` - `HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK`
<br>If set, do not check for broken dependents after installing, upgrading or reinstalling formulae. <br>If set, do not check for broken dependents after installing, upgrading or reinstalling formulae.

View File

@ -2641,12 +2641,6 @@ If set, do not automatically update before running some commands e\.g\. \fBbrew
If set, do not use Bootsnap to speed up repeated \fBbrew\fR calls\. If set, do not use Bootsnap to speed up repeated \fBbrew\fR calls\.
. .
.TP .TP
\fBHOMEBREW_NO_BOTTLE_SOURCE_FALLBACK\fR
.
.br
If set, fail on the failure of installation from a bottle rather than falling back to building from source\.
.
.TP
\fBHOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK\fR \fBHOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK\fR
. .
.br .br