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:
    xcode-select --install
    
    If it's already installed, you will see a message confirming this.

Installing Homebrew

To install Homebrew, follow these steps:

  1. Visit Homebrew's official website.
  2. Copy the installation command provided on the homepage.
  3. Open the Terminal or iTerm and paste the following command:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  4. Enter your administrator password when prompted.
  5. Homebrew will display the directories it will use for installation. Press Enter to continue.
  6. Wait for the installation to complete.
  7. 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)"
    
  8. Verify the installation by checking the Homebrew version:
    brew --version
    
    If successful, it should return the installed version number.

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:

  1. Go to Homebrew's official documentation and search for "uninstall."
  2. Copy and run the following command in your terminal:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
    
  3. Confirm the uninstallation when prompted.
  4. If any directories remain due to permission issues, remove them manually:
    sudo rm -rf /opt/homebrew
    
  5. Finally, remove Homebrew’s path from your shell configuration:
    vi ~/.zprofile
    
    Delete the line referencing Homebrew and save the file (dd to delete the line, then :wq! to save and exit).
  6. Confirm Homebrew has been removed by running:
    brew --version
    
    If Homebrew is successfully uninstalled, this command should return an error.

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.

Subscribe to dadonk

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe