Homebrew installs packages by token, and similar names can point to different formulae, casks, or versioned variants. Searching before an install keeps the next command aimed at the intended package instead of the closest-looking match.
Formulae usually provide command-line tools and libraries, while casks manage applications, fonts, plugins, and other packaged artifacts. brew search checks formula names and cask tokens by default, and --formula or --cask narrows the result when the package type is already known.
Description searches help when the package purpose is clearer than its token. Exact regular-expression searches are useful after a broad match returns related names, because Homebrew treats text flanked by slashes as a pattern and returns an error when no formula or cask matches.
Related: How to check Homebrew package information
Related: How to install a Homebrew formula
Related: How to install a Homebrew cask
Steps to search for Homebrew packages:
- Search package names across formulae and casks.
$ brew search wget wget wget2 wgetpaste
brew search performs a substring search. Similar tokens can appear together, so do not assume the first result is the package to install.
- Limit the search to formulae.
$ brew search --formula wget wget wget2 wgetpaste
Use --formula when searching for command-line tools, libraries, services, or dependencies managed as Homebrew formulae.
Related: How to install a Homebrew formula - Limit the search to casks.
$ brew search --cask visual-studio-code visual-studio visual-studio-code visual-studio-code@insiders
Use --cask when searching for applications, fonts, plugins, or other app-style packages.
Related: How to install a Homebrew cask - Search formula descriptions when the token is unknown.
$ brew search --formula --desc "file retriever" ==> Formulae wget: Internet file retriever
For formulae, --desc searches package descriptions. For casks, it searches names and descriptions. Keep --formula or --cask in the command when the result should stay within one package type.
- Search for an exact token with a regular expression.
$ brew search '/^wget$/' wget
Slashes make the search text a regular expression. The ^ and $ anchors match the complete token, which avoids related results such as wget2 or wgetpaste.
- Confirm the selected package before using it in an install or upgrade command.
$ brew info --formula wget ==> wget: stable 1.25.0 (bottled), HEAD Internet file retriever https://www.gnu.org/software/wget/ Installed (on request) From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/w/wget.rb License: GPL-3.0-or-later ==> Installed Kegs and Versions wget 1.25.0 (92 files, 4.7MB) [Linked] ==> Dependencies Required (5): libidn2, libpsl, openssl@3, gettext, libunistring ##### snipped #####
Check the package type, description, source tap, install state, and dependencies before installing or changing the package.
Related: How to check Homebrew package information
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.