diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb
index 93730daced..1d15679186 100644
--- a/Library/Homebrew/cleanup.rb
+++ b/Library/Homebrew/cleanup.rb
@@ -2,6 +2,7 @@
# frozen_string_literal: true
require "utils/bottles"
+
require "utils/gems"
require "formula"
require "cask/cask_loader"
@@ -12,7 +13,7 @@ module Homebrew
#
# @api private
class Cleanup
- CLEANUP_DEFAULT_DAYS = 30
+ CLEANUP_DEFAULT_DAYS = Homebrew::EnvConfig.cleanup_periodic_full_days.to_i.freeze
private_constant :CLEANUP_DEFAULT_DAYS
# {Pathname} refinement with helper functions for cleaning up files.
diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb
index e6675f14f0..862b079c51 100644
--- a/Library/Homebrew/env_config.rb
+++ b/Library/Homebrew/env_config.rb
@@ -68,6 +68,11 @@ module Homebrew
"`~/.profile`, `~/.bash_profile`, or `~/.zshenv`:\n\n" \
' `export HOMEBREW_CASK_OPTS="--appdir=~/Applications --fontdir=/Library/Fonts"`',
},
+ HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS: {
+ description: "If set, `brew install`, `brew upgrade` and `brew reinstall` will cleanup all formulae " \
+ "when this number of days has passed.",
+ default: 30,
+ },
HOMEBREW_CLEANUP_MAX_AGE_DAYS: {
description: "Cleanup all cached files older than this many days.",
default: 120,
@@ -243,7 +248,8 @@ module Homebrew
},
HOMEBREW_NO_INSTALL_CLEANUP: {
description: "If set, `brew install`, `brew upgrade` and `brew reinstall` will never automatically " \
- "cleanup installed/upgraded/reinstalled formulae or all formulae every 30 days.",
+ "cleanup installed/upgraded/reinstalled formulae or all formulae every " \
+ "HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS days.",
boolean: true,
},
HOMEBREW_PRY: {
diff --git a/docs/Manpage.md b/docs/Manpage.md
index ed716a523b..2a0f1aa258 100644
--- a/docs/Manpage.md
+++ b/docs/Manpage.md
@@ -1687,6 +1687,11 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
`export HOMEBREW_CASK_OPTS="--appdir=~/Applications --fontdir=/Library/Fonts"`
+- `HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS`
+
If set, `brew install`, `brew upgrade` and `brew reinstall` will cleanup all formulae when this number of days has passed.
+
+ *Default:* `30`.
+
- `HOMEBREW_CLEANUP_MAX_AGE_DAYS`
Cleanup all cached files older than this many days.
@@ -1823,7 +1828,7 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
*Note:* While ensuring your downloads are fully secure, this is likely to cause from-source SourceForge, some GNU & GNOME-hosted formulae to fail to download.
- `HOMEBREW_NO_INSTALL_CLEANUP`
-
If set, `brew install`, `brew upgrade` and `brew reinstall` will never automatically cleanup installed/upgraded/reinstalled formulae or all formulae every 30 days.
+
If set, `brew install`, `brew upgrade` and `brew reinstall` will never automatically cleanup installed/upgraded/reinstalled formulae or all formulae every HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS days.
- `HOMEBREW_PRY`
If set, use Pry for the `brew irb` command.
diff --git a/manpages/brew.1 b/manpages/brew.1
index 5c4fd5506d..822caa2e63 100644
--- a/manpages/brew.1
+++ b/manpages/brew.1
@@ -2364,6 +2364,15 @@ Append these options to all \fBcask\fR commands\. All \fB\-\-*dir\fR options, \f
\fBexport HOMEBREW_CASK_OPTS="\-\-appdir=~/Applications \-\-fontdir=/Library/Fonts"\fR
.
.TP
+\fBHOMEBREW_CLEANUP_PERIODIC_FULL_DAYS\fR
+.
+.br
+If set, \fBbrew install\fR, \fBbrew upgrade\fR and \fBbrew reinstall\fR will cleanup all formulae when this number of days has passed\.
+.
+.IP
+\fIDefault:\fR \fB30\fR\.
+.
+.TP
\fBHOMEBREW_CLEANUP_MAX_AGE_DAYS\fR
.
.br
@@ -2622,7 +2631,7 @@ If set, forbid redirects from secure HTTPS to insecure HTTP\.
\fBHOMEBREW_NO_INSTALL_CLEANUP\fR
.
.br
-If set, \fBbrew install\fR, \fBbrew upgrade\fR and \fBbrew reinstall\fR will never automatically cleanup installed/upgraded/reinstalled formulae or all formulae every 30 days\.
+If set, \fBbrew install\fR, \fBbrew upgrade\fR and \fBbrew reinstall\fR will never automatically cleanup installed/upgraded/reinstalled formulae or all formulae every HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS days\.
.
.TP
\fBHOMEBREW_PRY\fR