keepcalculator

06 Numbers and Powers

Uninstall Packages Homebrew Mac: Full Guide

Card No. 06·85092 · Updated · Standard formula, shown below

To uninstall a package installed with Homebrew on a Mac, you use the brew uninstall command followed by the package name. This removes the software and its associated files that Homebrew manages, though some configuration files may remain in your home directory. Below is a complete guide covering the commands, what they do, and how to handle common situations.

What Homebrew Uninstall Does

Homebrew is a package manager for macOS that installs software into its own directory, typically /opt/homebrew on Apple Silicon Macs or /usr/local on Intel Macs. When you run brew uninstall <formula>, Homebrew deletes the binaries, libraries, and other files it placed in that directory. It does not remove files the software created outside of Homebrew’s control, such as user preferences in ~/Library/Preferences or data in ~/Library/Application Support. This is a key distinction: uninstalling via Homebrew is cleaner than dragging an app to the Trash, but it is not a complete system wipe.

Basic Uninstall Command

The most straightforward way to remove a package is:

brew uninstall <package-name>

For example, to remove the wget utility, you would run:

brew uninstall wget

Homebrew will output the name of the package and confirm it has been removed. If the package has dependencies that were installed specifically for it, Homebrew will list them and ask if you want to remove them as well. You can type y to confirm or n to keep them.

Removing Dependencies and Orphans

Over time, you may accumulate packages that are no longer needed because their parent package was removed. These are called orphans. To see a list of all orphaned packages, run:

brew autoremove

This command removes all packages that were installed as dependencies but are no longer required by any installed formula. If you want to review what will be removed before proceeding, you can first run brew deps --installed to see the dependency tree, but brew autoremove is safe and only removes orphans. For a more granular approach, you can manually uninstall a specific dependency with brew uninstall <dependency> if you are sure nothing else uses it.

Uninstalling Casks (GUI Apps)

Homebrew also manages graphical applications through “casks.” These are installed with brew install --cask <app-name>. To uninstall a cask, use the same command with the --cask flag:

brew uninstall --cask <app-name>

For example, to remove Google Chrome if it was installed via Homebrew:

brew uninstall --cask google-chrome

This removes the application bundle from /Applications and its associated files in the Homebrew Caskroom. However, it does not delete user preferences or saved passwords stored in your home folder. To fully remove those, you would need to manually delete files in ~/Library related to the app.

Common Problems and Solutions

Sometimes uninstalling does not go as expected. Here are a few issues you might encounter:

  • “No such keg” error: This means the package is not installed via Homebrew, or it was already removed. Double-check the name with brew list.
  • Permission denied: If you see a permissions error, you may need to run the command with sudo, but this is rare because Homebrew usually installs to user-owned directories. If you are using an Intel Mac with the default /usr/local location, you might need to adjust ownership first.
  • Package still appears in PATH: After uninstalling, your shell might still find the old binary if it is cached. Run hash -r or restart your terminal to refresh the command lookup.
  • Dependencies left behind: If you want to remove all dependencies that are no longer needed, run brew autoremove as mentioned above.

How to Uninstall Homebrew Itself

If you want to remove Homebrew entirely, you can use the official uninstall script. This is a separate process from uninstalling individual packages. The script removes Homebrew’s installation directory, its caches, and the symlinks it created in /opt/homebrew or /usr/local. To run it, open a terminal and execute:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

This script will ask for confirmation before deleting. It is safe to run even if you have already uninstalled all packages. After running it, you may want to manually remove the empty /opt/homebrew directory if it remains, and check your shell configuration files (~/.zshrc or ~/.bash_profile) for any lines that add Homebrew to your PATH.

What About Configuration Files?

As noted, Homebrew does not remove configuration files that the software created in your home directory. For command-line tools, these are often dotfiles like ~/.wgetrc or ~/.gitconfig (though the latter is not managed by Homebrew). For GUI apps, look in ~/Library/Preferences and ~/Library/Application Support. If you want a completely clean removal, you must delete these manually. Be cautious: some configuration files are shared with other tools, so only delete the ones you are sure belong to the uninstalled package.

Frequently Asked Questions

How do I uninstall a package without removing its dependencies?

Simply run brew uninstall <package>. Homebrew will not automatically remove dependencies unless you explicitly tell it to. It will only prompt you if the package is a dependency of another installed package, in which case you cannot uninstall it without also removing the dependent package.

Can I reinstall a package after uninstalling?

Yes. Just run brew install <package> again. Homebrew will download and install the latest version. Your configuration files, if any, will remain, so the new installation may pick up your previous settings.

Does uninstalling a package free up disk space?

Yes, but only the space used by the files in Homebrew’s directory. If the package stored large data files in your home folder (like databases), those will remain. To check how much space a package uses, you can run brew info <package> and look at the “Installed” size.

What is the difference between brew uninstall and brew remove?

There is no difference. brew remove is an alias for brew uninstall and both do the same thing.

How do I uninstall a specific version of a package?

Homebrew generally keeps only one version of a formula installed at a time. If you have multiple versions (which is rare), you can list them with brew list --versions and then uninstall the specific version by appending @version to the package name, like brew uninstall python@3.9.

Will uninstalling a package affect other software?

Only if that software depends on the package. Homebrew will warn you if you try to uninstall a package that is a dependency of another installed formula. In that case, you must either uninstall the dependent package first or use --ignore-dependencies (not recommended as it can break things).

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →