macOS

How to install and use Homebrew on macOS

In this tutorial, you will discover how to install and setup Homebrew on your Mac. If that sounds interesting, let's jump in.
Captain Salem 3 min read
How to install and use Homebrew on macOS

Homebrew, commonly known as brew is a free and open-source package manager for macOS or Linux systems. It provides a simple and poweful command-line interface for installing, removing, updating and managing packages on your system. Homebrew allows you to install a wide collection of free and open source tools on macOS.

Requirements

To successfully follow along with this tutorial, ensure you have the following:

  • macOS Cataline and higher.
  • Administritive permissions
  • Network connectivity

Let's get started.

Step 1 - Launch the macOS Terminal Utility

When installing packages on your Mac using Homebrew, you will be using the terminal utility. Navigate to Applications -> Utilities -> Terminal.

You can also open the Spotlight Search and enter Terminal.

image-20220929182811969

Once you have the terminal session ready, we can proceed.

Step 2 - Install Xcode Command Line Tools

Xcode is a development environment for macOS. It provides a suite of tools and dependencies that are required to run various packages.

Although you won't need Xcode to use Homebrew, it is required to ensure that the packages you install with Homebrew function properly.

To install xcode tools, run the command:

xcode-select --install

The command will prompt to accept the installation process. You will also be prompted to read and accept the licenses  for the provide tools.

Wait for the process to complete and proceed to the next step.

Step 3 - Installing Homebrew

Once Xcode tools are setup, run the command below to download the Homebrew installer script:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

NOTE: It is good to ensure that you are comfortable with the operations executed by the installer script. You can navigate to the installer file in the link below:

https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh

Enter the administrator password to install Homebrew.

The installer script will download and configure the system for Homebrew. The script may provide you with commands to learn to add Homebrew to the path. Follow the requested instructions.

Once completed, you should have Homebrew installed and ready to go.

You can confirm by running the command:

brew --version

This should return the installed brew version as:

Homebrew 3.6.3
Homebrew/homebrew-core (git revision 89380db84dc; last commit 2022-09-29)
Homebrew/homebrew-cask (git revision 5df420c2ae; last commit 2022-09-29)

Brew Search Packages

Once you have installed Homebrew, you can search for the package you wish to install by running the command:

brew search <target_package_name>

For example, to search for the package vim, we can run the command:

brew search --desc "vim"

This should return the matching packages as:

(base) csalem@macbook ~ % brew search vim
==> Formulae
avimetaedit neovim-qt pyvim vimpc viu vis macvim neovim-remote vim ✔ zsh-vi-mode          vit zim neovim pacvim vimpager vifm vip nim

==> Casks
fvim goneovim kindavim macvim via vimediamanager vimr vym

You can also search packages in the brew homepage provided below:

https://brew.sh/

Brew Install Package

Once you find the package you wish to install, run the brew install command followed by the name of the package you wish to install:

brew install vim

The command should install the specified package and all the required dependencies.

(base) csalem@macbook ~ % brew install vim
==> Downloading https://ghcr.io/v2/homebrew/core/vim/manifests/9.0.0350_1
....

Brew Uninstall Package

To remove an existing package using Homebrew, run the brew uninstall command followed by the name of the package you wish to remove.

brew uinistall vim

Output:

Uninstalling /opt/homebrew/Cellar/vim/9.0.0350_1... (2,083 files, 37.8MB)

Remove Homebrew From Your System

If you no longer need Homebrew as your package manager, you can uninstall it by running the command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

The command above should download the uninstaller script and run it on your system.

Follow along the provided prompts to remove Homebrew from your system.

Fina Thoughts.

In this post you explored how to install and used Homebrew package manager on your macOS system. You can now use Homebrew to install tools, command-line utilities, updating packages, managing services, and more.

We hope this article helped you. Leave a comment download below and share this post.

Thanks for reading...

If you enjoy our content, please consider buying us a coffee to support our work:

Share
Comments
More from GeekBits

Join us at GeekBits

Join our members and get a currated list of awesome articles each month.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to GeekBits.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.