How to Uninstall Homebrew on macOS

Step-by-Step Guide to Uninstall Homebrew
Step 1: Run the Uninstall Script
Homebrew provides an official uninstall script that removes most of its files and configurations. Open your Terminal and run the following command:
1 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" |
This script will prompt you to confirm the uninstallation. Type y
and press Enter to proceed.
Step 2: Verify the Uninstallation
After running the uninstall script, check if Homebrew has been successfully removed by running:
1 | brew --version |
If Homebrew is fully uninstalled, you should see a “command not found” error. If you still see the version number, proceed to the next steps.
Step 3: Manually Remove Remaining Files
The uninstall script may leave behind some residual files. To ensure a complete cleanup, manually remove the following directories:
1 | sudo rm -rf /usr/local/Homebrew |
Note: Be cautious when running these commands, as they will delete all contents in the specified directories.
Step 4: Clean Up Configuration Files
Homebrew may have added paths or environment variables to your shell configuration files. Check and edit the following files to remove any Homebrew-related entries:
~/.bash_profile
~/.zshrc
~/.profile
Open these files in a text editor (e.g., nano ~/.zshrc
) and remove lines that reference Homebrew. Look for entries like export PATH="/usr/local/bin:$PATH"
or eval $(/opt/homebrew/bin/brew shellenv)
.
Step 5: Remove Cached Files
Homebrew stores cached files that may not be removed by the uninstall script. Run the following command to locate and remove these files:
1 | rm -rf $(brew --cache) |
This command will delete the cache directory used by Homebrew.
Step 6: Final Check
To ensure that no Homebrew files remain on your system, use the find
command to search for any leftover files:
1 | find / -name '*brew*' -print |
If you find any remaining files, you can manually delete them using the rm
command.
Additional Tips
Remove Brew Services: If you have used Homebrew services, stop and remove them using:
1
2brew services list
brew services stop --allCheck for Old Versions: If you have multiple versions of Homebrew installed, ensure you remove all of them.
Use Third-Party Tools: If you prefer a GUI-based approach, tools like PowerMyMac can help remove Homebrew and its associated files.
Conclusion
Uninstalling Homebrew from your macOS system is a straightforward process that involves running the official uninstall script and manually cleaning up residual files. By following the steps outlined in this guide, you can ensure a complete removal of Homebrew and its associated files. This will leave your system free of unnecessary files and ready for a fresh start.