Revert "Enable HOMEBREW_AUTOREMOVE by autoremove_default"

`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 3d114161b3c3f1a95b94e8530f5bc45bb44bbbd9.
This reverts commit efb14a0ec264c4ef408dbbd5330905dd230e979c.
This commit is contained in:
Carlo Cabrera 2024-05-25 21:59:51 +08:00
parent f1a7d971f2
commit ffd6c1f5c3
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
6 changed files with 20 additions and 26 deletions

View File

@ -287,11 +287,7 @@ module Homebrew
cleanup_formula(formula, quiet:, ds_store: false, cache_db: false) cleanup_formula(formula, quiet:, ds_store: false, cache_db: false)
end end
if ENV["HOMEBREW_AUTOREMOVE"].present? Cleanup.autoremove(dry_run: dry_run?) if Homebrew::EnvConfig.autoremove?
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_cache cleanup_cache
cleanup_empty_api_source_directories cleanup_empty_api_source_directories

View File

@ -77,11 +77,7 @@ module Homebrew
) )
end end
if ENV["HOMEBREW_AUTOREMOVE"].present? Cleanup.autoremove if Homebrew::EnvConfig.autoremove?
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?
end end
end end
end end

View File

@ -48,6 +48,12 @@ module Homebrew
"trying any other/default URLs.", "trying any other/default URLs.",
boolean: true, 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.",
boolean: true,
},
HOMEBREW_AUTO_UPDATE_SECS: { HOMEBREW_AUTO_UPDATE_SECS: {
description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \ description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \
"e.g. `brew install`, `brew upgrade` and `brew tap`. Alternatively, " \ "e.g. `brew install`, `brew upgrade` and `brew tap`. Alternatively, " \
@ -306,11 +312,6 @@ module Homebrew
"For more information, see: <https://docs.brew.sh/Analytics>", "For more information, see: <https://docs.brew.sh/Analytics>",
boolean: true, 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: { HOMEBREW_NO_AUTO_UPDATE: {
description: "If set, do not automatically update before running some commands, e.g. " \ description: "If set, do not automatically update before running some commands, e.g. " \
"`brew install`, `brew upgrade` and `brew tap`. Preferably, " \ "`brew install`, `brew upgrade` and `brew tap`. Preferably, " \

View File

@ -28,6 +28,9 @@ module Homebrew::EnvConfig
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def artifact_domain_no_fallback?; end def artifact_domain_no_fallback?; end
sig { returns(T::Boolean) }
def autoremove?; end
sig { returns(T.nilable(::String)) } sig { returns(T.nilable(::String)) }
def auto_update_secs; end def auto_update_secs; end
@ -193,9 +196,6 @@ module Homebrew::EnvConfig
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def no_auto_update?; end def no_auto_update?; end
sig { returns(T::Boolean) }
def no_autoremove?; end
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def no_bootsnap?; end def no_bootsnap?; end

View File

@ -3519,6 +3519,12 @@ command execution e.g. `$(cat file)`.
both set, if the request to `HOMEBREW_ARTIFACT_DOMAIN` fails then it Homebrew both set, if the request to `HOMEBREW_ARTIFACT_DOMAIN` fails then it Homebrew
will error rather than trying any other/default URLs. 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` `HOMEBREW_AUTO_UPDATE_SECS`
: Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some : Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some
@ -3837,11 +3843,6 @@ command execution e.g. `$(cat file)`.
: If set, do not send analytics. Google Analytics were destroyed. For more : If set, do not send analytics. Google Analytics were destroyed. For more
information, see: <https://docs.brew.sh/Analytics> 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` `HOMEBREW_NO_AUTO_UPDATE`
: If set, do not automatically update before running some commands, e.g. `brew : If set, do not automatically update before running some commands, e.g. `brew

View File

@ -2250,6 +2250,9 @@ Prefix all download URLs, including those for bottles, with this value\. For exa
\fBHOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK\fP \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\. 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 .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 \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\&\. 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 .RS
@ -2509,9 +2512,6 @@ If set, do not send analytics\. Google Analytics were destroyed\. For more infor
.UR https://docs\.brew\.sh/Analytics .UR https://docs\.brew\.sh/Analytics
.UE .UE
.TP .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 \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\. 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 .TP