Installing and Uninstalling Homebrew on MacOS
Installing and Uninstalling Homebrew on macOS
Homebrew is a popular package manager for macOS that simplifies the installation of software. This guide will walk you through installing, using, and uninstalling Homebrew on macOS.
What is Homebrew?
If you've used package managers like npm for Node.js or pip for Python, Homebrew works similarly but for macOS software. It allows you to install and manage packages easily via the command line.
Prerequisites
Before installing Homebrew, ensure that:
- You have an Apple Silicon or 64-bit Intel Mac running macOS 13 or higher.
- Your hardware is officially supported.
- You have Xcode command line tools installed. You can check by running:
If it's already installed, you will see a message confirming this.xcode-select --install
Installing Homebrew
To install Homebrew, follow these steps:
- Visit Homebrew's official website.
- Copy the installation command provided on the homepage.
- Open the Terminal or iTerm and paste the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Enter your administrator password when prompted.
- Homebrew will display the directories it will use for installation. Press Enter to continue.
- Wait for the installation to complete.
- Homebrew will provide three commands to set up your shell environment. Run these in the terminal:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
- Verify the installation by checking the Homebrew version:
If successful, it should return the installed version number.brew --version
Installing Packages with Homebrew
To test Homebrew, let's install wget
, a command-line utility for downloading files from the web:
brew install wget
Once installed, confirm it works by downloading Google’s homepage:
wget https://www.google.com
You should see an index.html
file in your directory.
Uninstalling Homebrew
If you no longer need Homebrew, you can remove it with the following steps:
- Go to Homebrew's official documentation and search for "uninstall."
- Copy and run the following command in your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
- Confirm the uninstallation when prompted.
- If any directories remain due to permission issues, remove them manually:
sudo rm -rf /opt/homebrew
- Finally, remove Homebrew’s path from your shell configuration:
Delete the line referencing Homebrew and save the file (vi ~/.zprofile
dd
to delete the line, then:wq!
to save and exit). - Confirm Homebrew has been removed by running:
If Homebrew is successfully uninstalled, this command should return an error.brew --version
Conclusion
Now you know how to install, use, and remove Homebrew on macOS. It’s a powerful tool that simplifies package management, making software installation easier for developers and power users alike.