LinuxCommandLibrary

brew-uninstall

Uninstall packages installed by Homebrew

TLDR

Uninstall a formula/cask

$ brew uninstall [formula|cask]
copy

Uninstall a cask and remove all associated files
$ brew uninstall --zap [cask]
copy

SYNOPSIS

brew uninstall [options] <formula>|<cask> ...

PARAMETERS

<formula>
    The name of the Homebrew formula (package) to uninstall.

<cask>
    The name of the Homebrew Cask (application) to uninstall. Requires the --cask option.

--force, -f
    Force uninstallation of a formula even if it is a dependency of another installed formula, or if it is keg-only.

--dry-run
    Show what would be uninstalled without actually performing the uninstallation.

--verbose, -v
    Print more verbose output during the uninstallation process.

--debug, -d
    Display debug information, useful for troubleshooting.

--cask
    Treat subsequent arguments as Casks. This option is required to uninstall Casks.

--formula
    Treat subsequent arguments as Formulae. This is the default behavior if neither --cask nor --formula is specified.

--zap
    For Casks, remove all associated files (app support, cache, preferences, etc.) as defined by the Cask. Use with caution as it can remove user data and settings.

DESCRIPTION

brew uninstall is the command used to remove software packages (formulae) and applications (casks) previously installed via Homebrew. It is the direct counterpart to brew install.

When a formula is uninstalled, Homebrew removes its files from the Cellar (Homebrew's installation prefix, typically /opt/homebrew or /usr/local/Cellar), along with any symbolic links in the Homebrew prefix's bin, sbin, etc., directories. For Casks, brew uninstall --cask <caskname> removes the application bundle from the Applications directory and any other associated files specified by the Cask definition.

This command is essential for managing disk space and keeping your system clean by removing unneeded software. It typically does not automatically remove dependencies that were installed alongside the package unless those dependencies are no longer required by any other installed formulae. Users often combine this with brew cleanup to remove old versions of installed packages.

CAVEATS

brew uninstall does not automatically remove unused dependencies. Unlike some other package managers (e.g., apt autoremove), Homebrew requires manual intervention or specific commands to clean up dependencies no longer needed by any installed formula.

Using --force can potentially break other installed formulae that rely on the uninstalled package. Use it only when you are certain the package is no longer needed by anything else.

The --zap option for Casks is very aggressive and will remove application data and user preferences. Always understand its implications before using it, as it can lead to data loss.

Files created by the uninstalled software outside of Homebrew's managed directories (e.g., in ~/.config or ~/Library/Application Support) are generally not removed by brew uninstall, unless the --zap option is used for Casks and the Cask specifically defines these locations for zapping.

DEPENDENCY MANAGEMENT

Homebrew's brew uninstall command will remove the specified formula or cask. However, it does not automatically remove dependencies that were installed alongside it but are no longer needed by any other formula. This means your system might accumulate 'orphaned' dependencies over time. To find unused dependencies, you may need to manually inspect brew leaves output or use community scripts. brew cleanup helps by removing old versions of formulae and stale files, but it does not remove unused dependencies themselves.

CASK UNINSTALLATION WITH --ZAP

When uninstalling a Cask (an application), the --zap option provides a more thorough removal. While a standard brew uninstall --cask typically removes only the application bundle from the Applications directory, --zap attempts to remove all files associated with the Cask, including application support files, caches, and preferences, as defined in the Cask's metadata. This can be very useful for a truly clean removal but should be used with extreme caution, as it can permanently delete user-specific data and settings for that application.

HISTORY

Homebrew was created by Max Howell in 2009 to provide a more 'Mac-friendly' package manager than existing solutions like MacPorts or Fink. The uninstall command has been a fundamental component since Homebrew's early days, serving as the essential method to remove installed software.

Initially focused solely on managing formulae (packages compiled from source), Homebrew later expanded its capabilities to include Casks (binary applications, typically graphical ones, like browsers or IDEs) through the homebrew-cask project. The brew cask uninstall command was eventually merged into the main brew uninstall command, accessed via the --cask option, streamlining the interface for managing both formulae and applications. This integration reflects Homebrew's continuous effort to simplify and unify package management on macOS and Linux.

SEE ALSO

brew(1), brew install(1), brew cleanup(1), brew list(1), brew doctor(1), brew unlink(1)

Copied to clipboard