Homebrew Uninstall And Reinstall Guide For Mac Mini M4
1. Completely Uninstall Homebrew
1.1 Run the official uninstall script
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Follow the prompts by typing y
and entering your administrator password.
1.2 Manually remove residual files
sudo rm -rf /opt/homebrew
rm -rf ~/Library/Caches/Homebrew
rm -rf ~/Library/Logs/Homebrew
1.3 Remove environment variables from your shell configuration
Edit ~/.zprofile
or ~/.zshrc
and delete the following line:
eval "$(/opt/homebrew/bin/brew shellenv)"
You can use the following command to open the file:
open ~/.zprofile
1.4 Verify if Homebrew was successfully uninstalled
brew
If it says command not found
, the uninstallation is complete.
2. Reinstall Homebrew
2.1 Installation command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This will automatically install the Xcode Command Line Tools (if not already installed).
2.2 Configure environment variables (must-do step)
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
2.3 Verify successful installation
brew doctor
If it says “Your system is ready to brew.”, the installation was successful.