Uninstall Homebrew
Here's how to completely remove Homebrew, the software package manager, on a Mac.
You may need to uninstall Homebrew if:
- Homebrew isn't behaving as you expect and you want to install it from scratch.
- You are no longer using Homebrew and you want to free storage space.
- You want to use a different package manager (for example, MacPorts, Fink, or pkgin).
Before you get started
You'll need a terminal application to uninstall Homebrew. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and worth a try.
Steps
Here are the steps to remove Homebrew from a Mac.
- Uninstall Homebrew using the official uninstall script.
- Verify files are removed.
- Remove the Homebrew shell configuration (Apple silicon only).
Before you get started, take a moment to tell me What do you want to do next? so I know what else you need.
Running the uninstall script
Homebrew provides an official uninstall script that can be run remotely. Check the Homebrew GitHub repository to see if it has changed.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
It's easy to run the command directly in your terminal. Just copy and paste the command you see above (don't type the $
as it is just a cue to enter a command in the terminal). Curl will copy the script from GitHub and run it in the macOS bash shell environment.
You'll see a list of files that the uninstall process will remove.
Warning: This script will remove:
~/Library/Caches/Homebrew/
~/Library/Logs/Homebrew/
/opt/homebrew/.dockerignore
/opt/homebrew/.editorconfig
/opt/homebrew/.git/
/opt/homebrew/.github/
/opt/homebrew/.gitignore
/opt/homebrew/.vale.ini
/opt/homebrew/.vscode/
/opt/homebrew/CHANGELOG.md
/opt/homebrew/CONTRIBUTING.md
/opt/homebrew/Caskroom/
/opt/homebrew/Cellar/
/opt/homebrew/Dockerfile
/opt/homebrew/LICENSE.txt
/opt/homebrew/Library//
/opt/homebrew/README.md
/opt/homebrew/bin/brew
/opt/homebrew/completions/
/opt/homebrew/docs/
/opt/homebrew/manpages/
Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] y
==> Removing Homebrew installation...
==> Removing empty directories...
Password:
You'll need to enter y
at the prompt. Then enter your password (the password you use to log in to your macOS account).
Finally you'll see a completion message along with a list of files you may need to remove yourself.
==> Homebrew uninstalled!
The following possible Homebrew files were not deleted:
/opt/homebrew/Frameworks/
/opt/homebrew/SECURITY.md
/opt/homebrew/bin/
/opt/homebrew/etc/
/opt/homebrew/include/
/opt/homebrew/lib/
/opt/homebrew/opt/
/opt/homebrew/sbin/
/opt/homebrew/share/
/opt/homebrew/var/
You may wish to remove them yourself.
Continue below to remove the Homebrew shell configuration and delete Homebrew residual files.
Alternative: downloading and running uninstall script
Some developers don't like to run scripts without first downloading and reviewing the script. If that's you, you can download the uninstall script with the curl -O
option to save to disk using a default file name.
$ curl -O https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
Then run /bin/bash uninstall.sh --help
to view uninstall options. You'll see this:
$ /bin/bash uninstall.sh --help
Homebrew Uninstaller
Usage: [NONINTERACTIVE=1] uninstall.sh [options]
-p, --path=PATH Sets Homebrew prefix. Defaults to /opt/homebrew.
--skip-cache-and-logs
Skips removal of HOMEBREW_CACHE and HOMEBREW_LOGS.
-f, --force Uninstall without prompting.
-q, --quiet Suppress all output.
-n, --dry-run Simulate uninstall but don't remove anything.
-h, --help Display this message.
NONINTERACTIVE Imply --force if NONINTERACTIVE is non-empty.
The uninstall script removes all Homebrew files, including installed packages in the /opt/homebrew/
(Apple silicon) or /usr/local/
(Mac Intel) directories. It doesn't remove the shell configuration required to run Homebrew.
Remove Homebrew shell configuration
On Apple silicon, the Homebrew shell configuration sets the $PATH
variable so Homebrew packages in the /opt/homebrew/
directory will be found and given priority in the terminal. No shell configuration is needed on Mac Intel because the /usr/local/
directory is included in the default $PATH
variable.
By default, the ~/.zprofile
file will contain configuration commands. Use the cat
command to display the contents of the file.
$ cat ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Remove the line that contains brew shellenv
. If you haven't installed a favorite text editor, use open ~/.zprofile
to open TextEdit so you can edit the file. You can remove the file with rm ~/.zprofile
if it contains only the Homebrew shell configuration.
Though the ~/.zprofile
file is recommended, someone may have installed Homebrew without the ~/.zprofile
file to set the shell configuration. If Homebrew is working but the ~/.zprofile
file does not contain the brew shellenv
command, check the other startup files that configure Zsh (listed below in the order they are sourced).
~/.zshenv
- sourced every time a shell is launched~/.zprofile
- sourced before~/.zshrc
, read only on login and intended for a user (not read by scripts)~/.zshrc
- the most common location for zsh configuration settings (for a user, not read by scripts)~/.zlogin
- sourced after~/.zshrc
and intended for remote login to a shell
In all likelihood, Homebrew shell configuration is set in ~/.zprofile
or ~/.zshrc
. There's also a possibility that shell configuration is set by Oh My Zsh, an advanced framework for managing a Zsh configuration. Just remove the line that contains brew shellenv
.
If you don't remove the Homebrew shell configuration and you've removed Homebrew, you'll see a warning message every time you start a terminal session.
Remove residual files
Remove all the remaining Homebrew files by removing the /opt/homebrew/
directory. You must use the sudo
command to get superuser privileges to remove the directory.
$ sudo rm -rf /opt/homebrew/
Check that the directory is gone, as well as the Homebrew log and cache folders in your user Library
directory.
$ ls -ag /opt
total 0
drwxr-xr-x 2 wheel 64 Jul 17 19:32 .
drwxr-xr-x 20 wheel 640 Jan 1 2020 ..
$ ls ~/Library/Caches/Homebrew/
ls: /Users/daniel/Library/Caches/Homebrew/: No such file or directory
$ ls ~/Library/Logs/Homebrew/
ls: /Users/daniel/Library/Logs/Homebrew/: No such file or directory
You've completely removed Homebrew.
You can follow instructions to Uninstall Xcode Command Line Tools if you want to further reduce dependencies.
What's next
That's it! You've uninstalled Homebrew.
For a guide that shows how to reinstall Homebrew, see Install Homebrew. After installing Homebrew, you can Install a Homebrew package.
My mac.install.guide is a trusted source of installation guides for professional developers. Take a look at the Mac Install Guide home page for tips and trends and see what to install next.