ClearDisk
Buy for $10Download ClearDiskDownload
A LITTLE MORE CLARITY

How to uninstall Homebrew on Mac

Back up your installed packages with brew bundle dump, stop active brew services, and run the official Homebrew uninstall.sh script (previewing with --dry-run first) to remove the Cellar and Caskroom. Afterwards, delete any leftover data folders in /opt/homebrew or /usr/local and remove the brew shellenv line from ~/.zprofile.

1. Save a list and stop services

brew bundle dump writes every tap, formula and cask you have into a Brewfile, the easiest way back if you change your mind; the listing guide linked below explains the other list commands. Then run brew services list. A service started with brew services has a launch agent file in ~/Library/LaunchAgents, and brew services stop both stops it and unregisters it, so nothing tries to start a deleted program at login.

Check for data before code. A database installed with Homebrew, such as PostgreSQL or MySQL, usually keeps its data under $(brew --prefix)/var. Export anything you need with the database’s own tools first. Configuration files you edited live under $(brew --prefix)/etc.

brew bundle dump --file=~/Brewfile
brew services list
brew services stop postgresql@17

2. Uninstall every cask and formula

Start with casks, because some casks depend on formulae. brew uninstall --cask removes each app from Applications along with Homebrew’s record of it. Adding --zap also deletes the app’s preferences and support files, and Homebrew warns that this may remove files shared with other apps, so keep it for apps you are finished with entirely.

Then pass every formula to brew uninstall in one command. Homebrew only blocks a removal when a formula or cask that is staying depends on it, so removing them together avoids dependency errors. brew list should then print nothing. If you only wanted a smaller Homebrew, uninstall the leaves you no longer use and let brew autoremove take their dependencies instead, as the cache guide shows.

brew list --cask
brew uninstall --cask $(brew list --cask)
brew uninstall $(brew list --formula)
brew list

3. Preview the official uninstall script

Homebrew’s FAQ points to the uninstall script in the Homebrew/install repository on GitHub. Its README gives a one-line command that downloads and runs the script, and also suggests downloading it first and running it with --help. Downloading first lets you read it and, more usefully, run it with --dry-run, which prints each “Would delete” line without removing anything.

The other options: --skip-cache-and-logs keeps Homebrew’s cache and log folders, -f or --force skips the confirmation question, and -p or --path points the script at a specific prefix. That last one matters on an Apple silicon Mac migrated from an Intel one, which can have both /opt/homebrew and an old /usr/local install. The script picks one, so check the dry run names the one you mean, and run it again with --path=/usr/local for the other.

curl -fsSLo uninstall.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
/bin/bash uninstall.sh --help
/bin/bash uninstall.sh --dry-run

4. Run it and read what it leaves

Run the script without --dry-run and answer y when it asks whether you are sure. It asks for your administrator password where it needs sudo. It deletes the Cellar and Caskroom, Homebrew’s own files, broken links, empty folders, and Homebrew’s caches and logs. Apps from casks you did not uninstall in step 2 stay in Applications; they keep working, but nothing updates them any more.

It then prints “The following possible Homebrew files were not deleted” with a list. These are folders that still contain something: configuration in etc, data in var, and packages that npm or pip installed into Homebrew’s lib folder. On Apple silicon, the /opt/homebrew folder itself also stays. Review the list, keep any data you need, and move the rest to the Trash with Finder’s Go → Go to Folder. On an Intel Mac, remove only the listed items: other installers, including the nodejs.org package, also use /usr/local.

/bin/bash uninstall.sh

5. Tidy your shell profile

Homebrew’s installer asks you to add a line containing brew shellenv to ~/.zprofile. Once brew is gone, that line fails in every new Terminal window with “no such file or directory: /opt/homebrew/bin/brew”. Delete the line, open a new window, and check that which brew finds nothing.

Homebrew’s installer may also have installed Apple’s Command Line Tools. They are Apple software rather than part of Homebrew, git and the compilers depend on them, and the uninstall script leaves them in place; the Command Line Tools guide explains how to check or reinstall them.

grep -n "brew shellenv" ~/.zprofile ~/.zshrc
which brew

Common questions

Does uninstalling Homebrew remove the apps it installed?

Not unless you uninstall them first. Apps from casks you didn't remove beforehand stay in Applications and keep working, but nothing updates them anymore once Homebrew is gone.

What files does Homebrew's uninstall script leave behind?

It prints a list of "possible Homebrew files" that weren't deleted, including configuration in etc, data in var, and packages npm or pip installed into Homebrew's lib folder. On Apple silicon, the /opt/homebrew folder itself also stays.

Can I see what Homebrew's uninstall script will delete before running it?

Yes, download the script first and run it with --dry-run, which prints each "Would delete" line without actually removing anything.

Does uninstalling Homebrew also remove the Xcode Command Line Tools?

No. They're Apple software rather than part of Homebrew, and the uninstall script leaves them in place even though Homebrew's installer may have installed them originally.

References & further reading

These guides combine the linked official guidance with ClearDisk’s documented behavior. Your files and app settings determine the right next step.

Main guide: developer storage on Mac · Related pillar: clear Xcode Derived Data on Mac · Browse all Developer storage guides →

FROM A NUMBER TO AN ANSWER

See what’s using
your space.

Explore your Mac with ClearDisk’s free local scanner.
Review the files. Keep the control.

Download free scannermacOS 15+ · version 2.2.1Cleanup license: $10 once