Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
40.74k stars 9.55k forks source link

Homebrew cleanup message appearing after every command #17869

Closed tgaeta closed 1 month ago

tgaeta commented 1 month ago

brew doctor output

brew doctor
Your system is ready to brew.
Usage: brew cleanup [options] [formula|cask ...]

Remove stale lock files and outdated downloads for all formulae and casks, and
remove old versions of installed formulae. If arguments are specified, only do
this for the given formulae and casks. Removes all downloads more than 120 days
old. This can be adjusted with HOMEBREW_CLEANUP_MAX_AGE_DAYS.

      --prune                      Remove all cache files older than specified
                                   days. If you want to remove everything, use
                                   --prune=all.
  -n, --dry-run                    Show what would be removed, but do not
                                   actually remove anything.
  -s, --scrub                      Scrub the cache, including downloads for even
                                   the latest versions. Note that downloads for
                                   any installed formulae or casks will still
                                   not be deleted. If you want to delete those
                                   too: rm -rf "$(brew --cache)"
      --prune-prefix               Only prune the symlinks and directories from
                                   the prefix and remove no other files.
  -d, --debug                      Display any debugging information.
  -q, --quiet                      Make some output more quiet.
  -v, --verbose                    Make some output more verbose.
  -h, --help                       Show this message.
Error: invalid option: -l

Verification

brew config output

brew config
HOMEBREW_VERSION: 4.3.10
ORIGIN: https://github.com/Homebrew/brew
HEAD: c3ae0327c01aab461531bfc0fcdfb4dd3a779205
Last commit: 8 days ago
Core tap JSON: 26 Jul 13:56 UTC
Core cask tap JSON: 26 Jul 13:56 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 3.3.3 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.3/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 15.0.0 build 1500
Git: 2.45.1 => /opt/homebrew/bin/git
Curl: 8.6.0 => /usr/bin/curl
macOS: 14.5-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: N/A
Rosetta 2: false
Usage: brew cleanup [options] [formula|cask ...]

Remove stale lock files and outdated downloads for all formulae and casks, and
remove old versions of installed formulae. If arguments are specified, only do
this for the given formulae and casks. Removes all downloads more than 120 days
old. This can be adjusted with HOMEBREW_CLEANUP_MAX_AGE_DAYS.

      --prune                      Remove all cache files older than specified
                                   days. If you want to remove everything, use
                                   --prune=all.
  -n, --dry-run                    Show what would be removed, but do not
                                   actually remove anything.
  -s, --scrub                      Scrub the cache, including downloads for even
                                   the latest versions. Note that downloads for
                                   any installed formulae or casks will still
                                   not be deleted. If you want to delete those
                                   too: rm -rf "$(brew --cache)"
      --prune-prefix               Only prune the symlinks and directories from
                                   the prefix and remove no other files.
  -d, --debug                      Display any debugging information.
  -q, --quiet                      Make some output more quiet.
  -v, --verbose                    Make some output more verbose.
  -h, --help                       Show this message.
Error: invalid option: -l

What were you trying to do (and why)?

I was trying to use various commands for normal day-to-day operations:

What happened (include all command output)?

After every command, regardless of its purpose or success, the following message appears:

Usage: brew cleanup [options] [formula|cask ...]
Remove stale lock files and outdated downloads for all formulae and casks, and
remove old versions of installed formulae. If arguments are specified, only do
this for the given formulae and casks. Removes all downloads more than 120 days
old. This can be adjusted with HOMEBREW_CLEANUP_MAX_AGE_DAYS.
      --prune                      Remove all cache files older than specified
                                   days. If you want to remove everything, use
                                   --prune=all.
  -n, --dry-run                    Show what would be removed, but do not
                                   actually remove anything.
  -s, --scrub                      Scrub the cache, including downloads for even
                                   the latest versions. Note that downloads for
                                   any installed formulae or casks will still
                                   not be deleted. If you want to delete those
                                   too: rm -rf "$(brew --cache)"
      --prune-prefix               Only prune the symlinks and directories from
                                   the prefix and remove no other files.
  -d, --debug                      Display any debugging information.
  -q, --quiet                      Make some output more quiet.
  -v, --verbose                    Make some output more verbose.
  -h, --help                       Show this message.
Error: invalid option: -l

What did you expect to happen?

I expected commands to execute normally without this cleanup message appearing every time.

Step-by-step reproduction instructions (by running brew commands)

Step-by-step reproduction instructions (by running brew commands):

Run any Homebrew command, for example:
brew update

Observe the normal output of the command.
Notice that the cleanup message appears at the end of the output.

Try another command, such as:
brew config

Again, observe that the cleanup message appears after the normal output.

This behavior occurs consistently with every terminal command, including brew --version, brew doctor, etc.

Additional Information:

- The issue persists after running brew update multiple times.
- The main brew script at /opt/homebrew/bin/brew appears to be normal and unmodified.
- The brew --version command outputs the version number correctly without the cleanup message.
- The issue occurs in both interactive and non-interactive shell sessions.
gromgit commented 1 month ago

This behavior occurs consistently with every terminal command, including brew --version, brew doctor, etc. [...] The brew --version command outputs the version number correctly without the cleanup message.

So does brew --version work correctly, or not? I'm betting it fails just like all the others, but please confirm one way or another.

Also, what's the output of type brew?

tgaeta commented 1 month ago

@gromgit Sorry for not mentioning in the original bug report, but I also ran those commands as well:

brew --version
Homebrew 4.3.10
Usage: brew cleanup [options] [formula|cask ...]

Remove stale lock files and outdated downloads for all formulae and casks, and
remove old versions of installed formulae. If arguments are specified, only do
this for the given formulae and casks. Removes all downloads more than 120 days
old. This can be adjusted with HOMEBREW_CLEANUP_MAX_AGE_DAYS.

      --prune                      Remove all cache files older than specified
                                   days. If you want to remove everything, use
                                   --prune=all.
  -n, --dry-run                    Show what would be removed, but do not
                                   actually remove anything.
  -s, --scrub                      Scrub the cache, including downloads for even
                                   the latest versions. Note that downloads for
                                   any installed formulae or casks will still
                                   not be deleted. If you want to delete those
                                   too: rm -rf "$(brew --cache)"
      --prune-prefix               Only prune the symlinks and directories from
                                   the prefix and remove no other files.
  -d, --debug                      Display any debugging information.
  -q, --quiet                      Make some output more quiet.
  -v, --verbose                    Make some output more verbose.
  -h, --help                       Show this message.
Error: invalid option: -l
type brew
brew is /opt/homebrew/bin/brew
Usage: brew cleanup [options] [formula|cask ...]

Remove stale lock files and outdated downloads for all formulae and casks, and
remove old versions of installed formulae. If arguments are specified, only do
this for the given formulae and casks. Removes all downloads more than 120 days
old. This can be adjusted with HOMEBREW_CLEANUP_MAX_AGE_DAYS.

      --prune                      Remove all cache files older than specified
                                   days. If you want to remove everything, use
                                   --prune=all.
  -n, --dry-run                    Show what would be removed, but do not
                                   actually remove anything.
  -s, --scrub                      Scrub the cache, including downloads for even
                                   the latest versions. Note that downloads for
                                   any installed formulae or casks will still
                                   not be deleted. If you want to delete those
                                   too: rm -rf "$(brew --cache)"
      --prune-prefix               Only prune the symlinks and directories from
                                   the prefix and remove no other files.
  -d, --debug                      Display any debugging information.
  -q, --quiet                      Make some output more quiet.
  -v, --verbose                    Make some output more verbose.
  -h, --help                       Show this message.
Error: invalid option: -l

I think this is a one-time thing. No one else reported it. I tried downgrading but still got the Error: invalid option: -l. Yesterday, everything was fine. This morning, I sat down to work, and the error came up.

gromgit commented 1 month ago

OK, so your brew isn't a wrapper or something else that's running brew cleanup with improper args. That leaves:

tgaeta commented 1 month ago

brew update-reset indeed resolved this issue for me. Thank you @gromgit 🙇