Skip to content

Commit

Permalink
Revert "Enable HOMEBREW_AUTOREMOVE by autoremove_default"
Browse files Browse the repository at this point in the history
`autoremove` is destructive, and it can be difficult for users to
recover from it occuring when they weren't expecting it.

Fixes #17363
Fixes Homebrew/discussions#5395

This reverts commit 3d11416.
This reverts commit efb14a0.
  • Loading branch information
carlocab committed May 25, 2024
1 parent f1a7d97 commit 6e0dc30
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
6 changes: 1 addition & 5 deletions Library/Homebrew/cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,7 @@ def clean!(quiet: false, periodic: false)
cleanup_formula(formula, quiet:, ds_store: false, cache_db: false)
end

if ENV["HOMEBREW_AUTOREMOVE"].present?
opoo "HOMEBREW_AUTOREMOVE is now a no-op as it is the default behaviour. " \
"Set HOMEBREW_NO_AUTOREMOVE=1 to disable it."
end
Cleanup.autoremove(dry_run: dry_run?) unless Homebrew::EnvConfig.no_autoremove?
Cleanup.autoremove(dry_run: dry_run?) if Homebrew::EnvConfig.autoremove?

cleanup_cache
cleanup_empty_api_source_directories
Expand Down
6 changes: 1 addition & 5 deletions Library/Homebrew/cmd/uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ def run
)
end

if ENV["HOMEBREW_AUTOREMOVE"].present?
opoo "HOMEBREW_AUTOREMOVE is now a no-op as it is the default behaviour. " \
"Set HOMEBREW_NO_AUTOREMOVE=1 to disable it."
end
Cleanup.autoremove unless Homebrew::EnvConfig.no_autoremove?
Cleanup.autoremove if Homebrew::EnvConfig.autoremove?
end
end
end
Expand Down
11 changes: 5 additions & 6 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ module EnvConfig
description: "If `HOMEBREW_ARTIFACT_DOMAIN` and `HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK` are both set, " \
"if the request to `HOMEBREW_ARTIFACT_DOMAIN` fails then it Homebrew will error rather than " \
"trying any other/default URLs.",
boolean: true,
},
HOMEBREW_AUTOREMOVE: {
description: "If set, calls to `brew cleanup` and `brew uninstall` will automatically " \
"remove unused formula dependents and if `HOMEBREW_NO_INSTALL_CLEANUP` is not set, " \
"`brew cleanup` will start running `brew autoremove` periodically.",
},
HOMEBREW_AUTO_UPDATE_SECS: {
description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \
Expand Down Expand Up @@ -306,11 +310,6 @@ module EnvConfig
"For more information, see: <https://docs.brew.sh/Analytics>",
boolean: true,
},
HOMEBREW_NO_AUTOREMOVE: {
description: "If set, calls to `brew cleanup` and `brew uninstall` will not automatically " \
"remove unused formula dependents.",
boolean: true,
},
HOMEBREW_NO_AUTO_UPDATE: {
description: "If set, do not automatically update before running some commands, e.g. " \
"`brew install`, `brew upgrade` and `brew tap`. Preferably, " \
Expand Down
3 changes: 0 additions & 3 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3519,6 +3519,12 @@ command execution e.g. `$(cat file)`.
both set, if the request to `HOMEBREW_ARTIFACT_DOMAIN` fails then it Homebrew
will error rather than trying any other/default URLs.

`HOMEBREW_AUTOREMOVE`

: If set, calls to `brew cleanup` and `brew uninstall` will automatically remove
unused formula dependents and if `HOMEBREW_NO_INSTALL_CLEANUP` is not set,
`brew cleanup` will start running `brew autoremove` periodically.

`HOMEBREW_AUTO_UPDATE_SECS`

: Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some
Expand Down Expand Up @@ -3837,11 +3843,6 @@ command execution e.g. `$(cat file)`.
: If set, do not send analytics. Google Analytics were destroyed. For more
information, see: <https://docs.brew.sh/Analytics>

`HOMEBREW_NO_AUTOREMOVE`

: If set, calls to `brew cleanup` and `brew uninstall` will not automatically
remove unused formula dependents.

`HOMEBREW_NO_AUTO_UPDATE`

: If set, do not automatically update before running some commands, e.g. `brew
Expand Down
6 changes: 3 additions & 3 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -2250,6 +2250,9 @@ Prefix all download URLs, including those for bottles, with this value\. For exa
\fBHOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK\fP
If \fBHOMEBREW_ARTIFACT_DOMAIN\fP and \fBHOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK\fP are both set, if the request to \fBHOMEBREW_ARTIFACT_DOMAIN\fP fails then it Homebrew will error rather than trying any other/default URLs\.
.TP
\fBHOMEBREW_AUTOREMOVE\fP
If set, calls to \fBbrew cleanup\fP and \fBbrew uninstall\fP will automatically remove unused formula dependents and if \fBHOMEBREW_NO_INSTALL_CLEANUP\fP is not set, \fBbrew cleanup\fP will start running \fBbrew autoremove\fP periodically\.
.TP
\fBHOMEBREW_AUTO_UPDATE_SECS\fP
Run \fBbrew update\fP once every \fBHOMEBREW_AUTO_UPDATE_SECS\fP seconds before some commands, e\.g\. \fBbrew install\fP, \fBbrew upgrade\fP and \fBbrew tap\fP\&\. Alternatively, disable auto\-update entirely with \fBHOMEBREW_NO_AUTO_UPDATE\fP\&\.
.RS
Expand Down Expand Up @@ -2509,9 +2512,6 @@ If set, do not send analytics\. Google Analytics were destroyed\. For more infor
.UR https://docs\.brew\.sh/Analytics
.UE
.TP
\fBHOMEBREW_NO_AUTOREMOVE\fP
If set, calls to \fBbrew cleanup\fP and \fBbrew uninstall\fP will not automatically remove unused formula dependents\.
.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\&\. Preferably, run this less often by setting \fBHOMEBREW_AUTO_UPDATE_SECS\fP to a value higher than the default\. Note that setting this 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
Expand Down

0 comments on commit 6e0dc30

Please sign in to comment.