Skip to content

Commit

Permalink
Merge pull request #10640 from MikeMcQuaid/bottle_source_fallback_def…
Browse files Browse the repository at this point in the history
…ault

Make HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK default
  • Loading branch information
MikeMcQuaid authored Feb 18, 2021
2 parents 2da3681 + 22e591e commit 3929abc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 61 deletions.
5 changes: 0 additions & 5 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,6 @@ module EnvConfig
description: "If set, do not use Bootsnap to speed up repeated `brew` calls.",
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: {
description: "If set, do not check for broken dependents after installing, upgrading or reinstalling " \
"formulae.",
Expand Down
73 changes: 26 additions & 47 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def initialize(
@options = options
@requirement_messages = []
@poured_bottle = false
@pour_failed = false
@start_time = nil
end

Expand Down Expand Up @@ -154,8 +153,6 @@ def build_bottle?

sig { params(output_warning: T::Boolean).returns(T::Boolean) }
def pour_bottle?(output_warning: false)
return false if @pour_failed

return false if !formula.bottle_tag? && !formula.local_bottle_path
return true if force_bottle?
return false if build_from_source? || build_bottle? || interactive?
Expand Down Expand Up @@ -235,30 +232,37 @@ def check_install_sanity
# homebrew-core and have full bottle coverage.
(OS.mac? || ENV["CI"]) &&
!build_from_source? && !build_bottle? &&
!installed_as_dependency? &&
formula.tap&.core_tap? && !formula.bottle_unneeded? && !formula.any_version_installed? &&
formula.tap&.core_tap? && !formula.bottle_unneeded? &&
# Integration tests override homebrew-core locations
ENV["HOMEBREW_TEST_TMPDIR"].nil? &&
!pour_bottle?
message = if !formula.pour_bottle? && formula.pour_bottle_check_unsatisfied_reason
formula_message = formula.pour_bottle_check_unsatisfied_reason
formula_message[0] = formula_message[0].downcase

"#{formula}: #{formula_message}"
else
<<~EOS
#{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
#{formula}: no bottle available!
EOS
end
message += <<~EOS
You can try to install from source with:
brew install --build-from-source #{formula}
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.
EOS
raise CannotInstallFormulaError, message

if message
message += <<~EOS
You can try to install from source with:
brew install --build-from-source #{formula}
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.
EOS
raise CannotInstallFormulaError, message
end
end

type, reason = DeprecateDisable.deprecate_disable_info formula
Expand Down Expand Up @@ -429,7 +433,7 @@ def install
if pour_bottle?
begin
pour
rescue Exception => e # rubocop:disable Lint/RescueException
rescue Exception # rubocop:disable Lint/RescueException
# any exceptions must leave us with nothing installed
ignore_interrupts do
begin
Expand All @@ -442,17 +446,7 @@ def install
end
formula.rack.rmdir_if_possible
end
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."
raise UnbottledError, [formula] unless DevelopmentTools.installed?

compute_and_install_dependencies unless ignore_deps?
raise
else
@poured_bottle = true
end
Expand Down Expand Up @@ -513,7 +507,7 @@ def check_conflicts

$stderr.puts "Please report this issue to the #{formula.tap} tap (not Homebrew/brew or Homebrew/core)!"
false
else # rubocop:disable Layout/ElseAlignment
else
f.linked_keg.exist? && f.opt_prefix.exist?
end

Expand Down Expand Up @@ -1123,25 +1117,10 @@ def fetch

return if only_deps?

if 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
unless pour_bottle?(output_warning: true)
formula.fetch_patches
formula.resources.each(&:fetch)
end
return if pour_bottle?

formula.fetch_patches
formula.resources.each(&:fetch)
downloader.fetch
end

Expand Down
3 changes: 0 additions & 3 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1858,9 +1858,6 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
- `HOMEBREW_NO_BOOTSNAP`
<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`
<br>If set, do not check for broken dependents after installing, upgrading or reinstalling formulae.

Expand Down
6 changes: 0 additions & 6 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -2653,12 +2653,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\.
.
.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
.
.br
Expand Down

0 comments on commit 3929abc

Please sign in to comment.