How to install a Homebrew formula

Homebrew formulae package command-line tools, libraries, and services under the active Homebrew prefix. Installing a formula by token is the normal path for adding a tool such as hello, wget, or git to a macOS, Linux, or WSL Homebrew setup.

A formula token identifies an entry from homebrew/core or another tapped repository. Checking metadata before installation shows the source, dependencies, bottle support, install state, and caveats, which is especially helpful when similar formula and cask names exist.

Formulae usually link executables into the active Homebrew prefix so shell commands become available after installation. Some formulae are keg-only and do not create those links automatically, so read any caveats before treating a successful install as a command on PATH.

Steps to install a Homebrew formula:

  1. Search for the formula token.
    $ brew search --formula hello
    hello
    jello
    helm

    Use the exact formula token from the result. The --formula option excludes casks from the search result.
    Related: How to search for Homebrew packages

  2. Inspect the formula metadata.
    $ brew info --formula hello
    ==> hello: stable 2.12.3 (bottled)
    Program providing model for GNU coding standards and practices
    https://www.gnu.org/software/hello/
    Not installed
    From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/h/hello.rb
    License: GPL-3.0-or-later
    ==> Dependencies
    Required (1): bubblewrap
    ##### snipped #####

    Check the package description, install state, source tap, dependencies, and caveats. Dependency lists and bottle architecture can differ between macOS, Linux, and WSL.
    Related: How to check Homebrew package information

  3. Install the formula.
    $ brew install --formula hello
    ==> Would install 1 formula:
    hello
    ==> Would install 2 dependencies for hello:
    libcap
    bubblewrap
    ==> Fetching downloads for: hello
    ##### snipped #####
    ==> Installing hello
    ==> Pouring hello--2.12.3.arm64_linux.bottle.tar.gz
    ##### snipped #####

    Homebrew may ask for confirmation before downloading. Add --yes only after reviewing the token and metadata. If the formula is already installed but outdated, brew install can upgrade it unless HOMEBREW_NO_INSTALL_UPGRADE is set.

  4. Confirm that Homebrew records the installed formula.
    $ brew list --formula --versions hello
    hello 2.12.3
  5. Check that the installed command resolves from the Homebrew prefix.
    $ command -v hello
    /home/linuxbrew/.linuxbrew/bin/hello

    On macOS, the path commonly starts with /opt/homebrew/bin on Apple Silicon or /usr/local/bin on Intel. If another path appears first, reload the Homebrew shell environment.
    Related: How to configure Homebrew shell environment

  6. Run the installed command.
    $ hello
    Hello, world!

    For a library-only or service formula, replace this smoke test with the package-specific file, header, library, or service check shown by brew info.