LinuxCommandLibrary

brew-autoremove

Remove orphaned Homebrew dependencies

TLDR

Remove unused dependencies
$ brew autoremove
copy
Preview what would be removed
$ brew autoremove --dry-run
copy

SYNOPSIS

brew autoremove [options]

DESCRIPTION

brew autoremove uninstalls formulae that were only installed as dependencies and are no longer needed by any installed formula. It cleans up orphaned dependencies left behind after uninstalling packages.

PARAMETERS

--dry-run, -n

List what would be removed without removing

HOW IT WORKS

When you install a package like git, dependencies (gettext, pcre2) are installed automatically. When you uninstall git, those dependencies remain. Running brew autoremove removes these orphaned dependencies.

EXAMPLE WORKFLOW

$ brew uninstall git          # Remove package
brew autoremove             # Clean up dependencies
brew cleanup                # Remove cached downloads
copy

PREVENTING REMOVAL

To prevent a formula from being removed by autoremove, mark it as "installed on request":

$ brew install formula
copy
This changes the formula's status from dependency to explicitly installed.

RELATED COMMANDS

brew leaves

Show top-level packages (not dependencies)
brew deps --installed
Show dependency tree
brew cleanup
Remove cached downloads and old versions

CAVEATS

Only removes formulae installed as dependencies, not those explicitly installed. Safe to run regularly after uninstalling packages. Does not remove casks.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard