Skip to content

Commit

Permalink
brew.rb: tell more people to not report issues.
Browse files Browse the repository at this point in the history
- We should tell people to not report issues if they are running in an
  unsupported configuration.
- We should tell people to run `brew update` before reporting issues if
  they have `HOMEBREW_NO_AUTO_UPDATE` set.
- We should tell people to not report issues in more types of
  exceptions.
- Warn people in `HOMEBREW_NO_AUTO_UPDATE` documentation.
  • Loading branch information
MikeMcQuaid committed Apr 2, 2024
1 parent 0b39a87 commit 737b120
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
35 changes: 27 additions & 8 deletions Library/Homebrew/brew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@
Utils::Analytics.report_build_error(e)
e.dump(verbose: args&.verbose?)

if e.formula.head? || e.formula.deprecated? || e.formula.disabled?
if Homebrew::EnvConfig.no_auto_update?

Check warning on line 151 in Library/Homebrew/brew.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/brew.rb#L151

Added line #L151 was not covered by tests
$stderr.puts "#{Tty.bold}Do not report this issue until you've run `brew update` and tried again.#{Tty.reset}"
elsif OS.unsupported_configuration?
$stderr.puts "#{Tty.bold}Do not report this issue: you are running in an unsupported configuration.#{Tty.reset}"
elsif e.formula.head? || e.formula.deprecated? || e.formula.disabled?
reason = if e.formula.head?
"was built from an unstable upstream --HEAD"
elsif e.formula.deprecated?
Expand All @@ -170,6 +174,12 @@

exit 1
rescue RuntimeError, SystemCallError => e
if Homebrew::EnvConfig.no_auto_update?
$stderr.puts "#{Tty.bold}Do not report this issue until you've run `brew update` and tried again.#{Tty.reset}"
elsif OS.unsupported_configuration?
$stderr.puts "#{Tty.bold}Do not report this issue: you are running in an unsupported configuration.#{Tty.reset}"
end

raise if e.message.empty?

onoe e
Expand All @@ -178,6 +188,13 @@
exit 1
rescue MethodDeprecatedError => e
onoe e

if Homebrew::EnvConfig.no_auto_update?

Check warning on line 192 in Library/Homebrew/brew.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/brew.rb#L192

Added line #L192 was not covered by tests
$stderr.puts "#{Tty.bold}Do not report this issue until you've run `brew update` and tried again.#{Tty.reset}"
elsif OS.unsupported_configuration?
$stderr.puts "#{Tty.bold}Do not report this issue: you are running in an unsupported configuration.#{Tty.reset}"
end

if e.issues_url
$stderr.puts "If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):"
$stderr.puts " #{Formatter.url(e.issues_url)}"
Expand All @@ -186,15 +203,17 @@
exit 1
rescue Exception => e # rubocop:disable Lint/RescueException
onoe e
if internal_cmd && !OS.unsupported_configuration?
if Homebrew::EnvConfig.no_auto_update?
$stderr.puts "#{Tty.bold}Do not report this issue until you've run `brew update` and tried again.#{Tty.reset}"
else
$stderr.puts "#{Tty.bold}Please report this issue:#{Tty.reset}"
$stderr.puts " #{Formatter.url(OS::ISSUES_URL)}"
end

if Homebrew::EnvConfig.no_auto_update?

Check warning on line 207 in Library/Homebrew/brew.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/brew.rb#L207

Added line #L207 was not covered by tests
$stderr.puts "#{Tty.bold}Do not report this issue until you've run `brew update` and tried again.#{Tty.reset}"
elsif internal_cmd && !OS.unsupported_configuration?
$stderr.puts "#{Tty.bold}Please report this issue:#{Tty.reset}"
$stderr.puts " #{Formatter.url(OS::ISSUES_URL)}"

Check warning on line 211 in Library/Homebrew/brew.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/brew.rb#L211

Added line #L211 was not covered by tests
elsif OS.unsupported_configuration?
$stderr.puts "#{Tty.bold}Do not report this issue: you are running in an unsupported configuration.#{Tty.reset}"
end
$stderr.puts Utils::Backtrace.clean(e)

exit 1
else
exit 1 if Homebrew.failed?
Expand Down
6 changes: 4 additions & 2 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,10 @@ module EnvConfig
},
HOMEBREW_NO_AUTO_UPDATE: {
description: "If set, do not automatically update before running some commands, e.g. " \
"`brew install`, `brew upgrade` and `brew tap`. Alternatively, " \
"run this less often by setting `HOMEBREW_AUTO_UPDATE_SECS` to a value higher than the default.",
"`brew install`, `brew upgrade` and `brew tap`. Preferably, " \
"run this less often by setting `HOMEBREW_AUTO_UPDATE_SECS` to a value higher than the " \
"default. Note that setting and e.g. tapping new taps may result in a broken configuration. " \
"Please ensure you always run `brew update` before reporting any issues.",
boolean: true,
},
HOMEBREW_NO_BOOTSNAP: {
Expand Down
6 changes: 4 additions & 2 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3740,8 +3740,10 @@ command execution e.g. `$(cat file)`.
`HOMEBREW_NO_AUTO_UPDATE`

: If set, do not automatically update before running some commands, e.g. `brew
install`, `brew upgrade` and `brew tap`. Alternatively, run this less often by
setting `HOMEBREW_AUTO_UPDATE_SECS` to a value higher than the default.
install`, `brew upgrade` and `brew tap`. Preferably, run this less often by
setting `HOMEBREW_AUTO_UPDATE_SECS` to a value higher than the default. Note
that setting and e.g. tapping new taps may result in a broken configuration.
Please ensure you always run `brew update` before reporting any issues.

`HOMEBREW_NO_BOOTSNAP`

Expand Down
2 changes: 1 addition & 1 deletion manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -2445,7 +2445,7 @@ If set, do not send analytics\. Google Analytics were destroyed\. For more infor
.UE
.TP
\fBHOMEBREW_NO_AUTO_UPDATE\fP
If set, do not automatically update before running some commands, e\.g\. \fBbrew install\fP, \fBbrew upgrade\fP and \fBbrew tap\fP\&\. Alternatively, run this less often by setting \fBHOMEBREW_AUTO_UPDATE_SECS\fP to a value higher than the default\.
If set, do not automatically update before running some commands, e\.g\. \fBbrew install\fP, \fBbrew upgrade\fP and \fBbrew tap\fP\&\. Preferably, run this less often by setting \fBHOMEBREW_AUTO_UPDATE_SECS\fP to a value higher than the default\. Note that setting and e\.g\. tapping new taps may result in a broken configuration\. Please ensure you always run \fBbrew update\fP before reporting any issues\.
.TP
\fBHOMEBREW_NO_BOOTSNAP\fP
If set, do not use Bootsnap to speed up repeated \fBbrew\fP calls\.
Expand Down

0 comments on commit 737b120

Please sign in to comment.