https://opensource.com/article/20/6/homebrew-mac
In my quest to "automate all the things," I have been on a journey to manage my Mac laptop as the code it inherently is. Instead of pointing and clicking to manually manage my applications and utilities, I prefer to use package management software to install, update, and remove unneeded software.
That's a challenge for Mac users. One place where the Mac operating system, macOS, has always been behind Linux is in package management. There is no default package manager for Mac users, while Linux users have many options—from the familiar yum
and apt
to the modern choice of Flatpak. But what about us?
This is where Homebrew comes in. Homebrew fills the void as the de facto package manager for macOS (and as another option for Linux). It provides an incredibly smooth and straightforward experience for anyone familiar with the command line, and it's a good way to learn the command line if you're new to it.
If you're on a Mac and don't already have Homebrew, you can install it with:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
This command executes the installer script provided by the Homebrew team. If you prefer to be more cautious, you can curl
the file, then run it manually after reviewing it:
$ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh --output homebrew_installer.sh
$ more homebrew_installer.sh # review the script until you feel comfortable
$ bash homebrew_installer.sh
Manage your command-line utilities with brew
Homebrew boasts that it "installs the stuff you need that Apple (or your Linux system) didn't" install by default. Installation happens with the brew
command, which gives us access to thousands of command-line utilities, but not more complex applications.
For us nerds, the utilities that fit into "the stuff you need" category include the handy tree
command that shows directory structures and pyenv
, which I use to manage multiple versions of Python.
You can see all the "formulae" that are available from Homebrew using the search
command, and I use the wc
command shows how many formulae there are:
# -l counts the number of lines
$ brew search | wc -l
5013
There are over 5,000 formulae, which is an incredible amount of software. So it's best to have an idea of what you want before searching that huge list. Thankfully, it is easy enough to browse. Formulae are codified and centralized into the core repositories that are split by operating system (Mac in Homebrew Core and Linux in Linux Core). They are also available through the Homebrew API and listed on the website.
Word of mouth is another great method to find utilitites. With that in mind, here are some of my favorites if you're looking for inspiration:
pyenv
,rbenv
, andnodenv
to manage Python, Ruby, and Node.js versions (respectively)imagemagick
for scriptable image editspandoc
for scriptable document conversions (I often switch from .docx to .md or .html)hub
for a better Git experience for GitHub userstldr
for examples of how to use a command-line utility
As an example, take a look at tldr pages, a user-friendly alternative to scrolling through an application's man pages. You can confirm it's available by running search
again:
$ brew search tldr
==> Formulae
tldr ✔
Success! The checkmark lets you know it is available. Now you can install it:
$ brew install tldr
==> Downloading https://homebrew.bintray.com/bottles/tldr-1.3.0_2.catalina.bottle.tar.gz
Already downloaded: /Users/mbbroberg/Library/Caches/Homebrew/downloads/901bc14594a9283e9ab20aec942dc5a9a2befb7e96e1b0fcccb4e3257918813c--tldr-1.3.0_2.catalina.bottle.tar.gz
==> Installing tldr
==> Pouring tldr-1.3.0_2.catalina.bottle.tar.gz
🍺 /usr/local/Cellar/tldr/1.3.0_2: 6 files, 35.5KB
Homebrew, thankfully, prebuilds the binaries, so you don't have to build from source code on your local machine. That saves a lot of time and CPU fan noise. Another thing I appreciate about Homebrew is that you can appreciate this feature without understanding exactly what it means.
But if you're into it, it can be fun to look at the complexity. Run info
on tldr
, and you can see all the dependency management, the source code, and even public analytics:
$ brew info tldr
tldr: stable 1.3.0 (bottled), HEAD
Simplified and community-driven man pages
https://tldr.sh/
Conflicts with: tealdeer (because both install `tldr` binaries)
/usr/local/Cellar/tldr/1.3.0_2 (6 files, 35.5KB) *
Poured from bottle on 2020-05-20 at 15:12:12
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/tldr.rb
==> Dependencies
Build: pkg-config ✔
Required: libzip ✔
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 2,811 (30 days), 7,875 (90 days), 27,105 (365 days)
install-on-request: 2,806 (30 days), 7,860 (90 days), 27,080 (365 days)
build-error: 0 (30 days)
Finally, as in any good package manager, Homebrew's brew uninstall
is available to quickly clean and remove unused utilities.
Manage your applications with brew casks
Command-line utilities are a blast, but what about full-blown applications? Homebrew keeps its standard commands simple and installs only single-file applications through its default brew
command-line interface. Applications don't fit that structure. They have a more complex directory hierarchy that is much more than a single binary.
Fortunately, Homebrew on Mac includes a subcommand called "casks" for more complex multi-directory structures. What's especially nice is that cask
uses a similar command structure to the standard brew
commands, so you can use similar search
, install
, and info
steps:
brew search --cask | wc -l
4772
Wow, there are nearly 5,000 more applications to browse, which are easier to peruse on Homebrew's website.
I'll walk you through cask
with one of my new favorite applications: Meld (which I read about on Opensource.com). It's a feature-rich editor that helps manage merge conflicts. There is a download on its website, and I could run through the installer and drag-and-drop it into my Applications folder, but I don't do that anymore. I use Homebrew.
First, I confirm it's available through a slightly different syntax:
$ brew search --casks meld
==> Casks
meld
Then I use the cask
sub-command to install it:
$ brew cask install meld
==> Downloading https://github.com/yousseb/meld/releases/download/osx-19/meldmerge.dmg
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/28624006/66cb25
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'meld'.
==> Installing Cask meld
==> Moving App 'Meld.app' to '/Applications/Meld.app'.
==> Linking Binary 'meld.wrapper.sh' to '/usr/local/bin/meld'.
🍺 meld was successfully installed!
Homebrew not only installs the application but also makes it available in my current path under /usr/local/bin/
. Now I can run meld
from the command line or launch the application from the Applications folder.
Update everything with brew upgrade
The main reason I consistently use a package manager is so that I can consistently upgrade my software to avoid known security bugs and ensure I always have the latest features. If I install everything by hand, I have to keep an eye on each tool and application to know whether it has an auto-updater and, if not, pull down the latest releases myself.
Upgrades are where great package management shines. Since I don't have any special version requirements, I run only one command to update everything smoothly:
$ brew upgrade
==> Upgrading 6 outdated packages:
helm 3.2.1 -> 3.2.2
python@3.8 3.8.2_4 -> 3.8.3
ipython 7.14.0 -> 7.15.0
go 1.14.2_1 -> 1.14.3
libzip 1.6.1 -> 1.6.1_1
sqlite 3.31.1 -> 3.32.1
If you have more complex needs or want to keep an eye on upgrades before installing them, there are plenty of feature flags available. For instance, -n
offers a "dry run" that lists available upgrades without installing them. You can also "pin" an application version to prevent upgrades.
Back up your installation
The command-line utility and application management jumps to a whole new level when tools allow you to back up your installation like any other dotfile in version control. Homebrew has that kind of functionality available to use under the dump
subcommand. It generates a Brewfile
, which is a reusable list of all the currently installed tools. To generate one from your installation, go into your preferred folder and run:
$ cd ~/Development/dotfiles # This is my dotfile folder
$ brew bundle dump
When I change machines and want to install the same applications with Homebrew, I go to the folder with the Brewfile and run:
$ brew bundle
It will install all the listed formulae and casks on my new machine.
Go to Homebrew for package management
More Great Content
- Free online course: RHEL technical overview
- Learn Advanced Linux Commands
- Download Cheat Sheets
- Find an Open Source Alternative
- Read Top Linux Content
- Check out open source resources
Homebrew is my go-to manager for command-line utilities and applications. It keeps me organized and up-to-date, and its design is a beautiful balance between ease of use and depth of functionality. Homebrew minimizes package management details to only what you need to know, and most users will benefit from that.
If you're already comfortable with Linux package managers, you may think Homebrew is too simple, but don't mistake Homebrew's ease of use for lack of features. Looking a little deeper reveals many advanced options that go far beyond what I showed you here. Adding -h
to any brew
subcommand shows the rich features available to upgrade, remove, troubleshoot, and even contribute new formulas using templates.
Overall, Homebrew makes being a command-line wielding Mac user a joy. In addition, it's open source, so you can contribute back to the code if you're so inclined. Give it a try, and let me know what you think by leaving a comment below.
Homebrew welcome message
Common Problems / Solutions
- Examples of common errors and their solutions
curl
errorPermission denied
errorChecksum does not match
errorsource is not there
errorwrong number of arguments
error- The app can’t be opened because it is from an unidentified developer
- My problem isn’t listed
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-homebrew-on-macos
Introduction
The command line interface is a non-graphical way to interact with your computer. Instead of clicking buttons with your mouse, you’ll type commands as text and receive text-based feedback. The command line, also known as a shell, lets you automate many tasks you do on your computer daily, and is an essential tool for software developers.
While the command line interface on macOS has a lot of the functionality you’d find in Linux and other Unix systems, it does not ship with a good package manager. A package manager is a collection of software tools that work to automate software installations, configurations, and upgrades. Package managers keep the software they install in a central location and can maintain all software packages on the system in formats that are commonly used.
Homebrew is a package manager for macOS which lets you install free and open-source software using your terminal. You’ll use Homebrew to install developer tools like Python, Ruby, Node.js, and more.
In this tutorial you’ll install and use Homebrew on your Mac.
Prerequisites
You will need a macOS computer running High Sierra or higher with administrative access and an internet connection.
Step 1 — Using the macOS Terminal
To access the command line interface on your Mac, you’ll use the Terminal application provided by macOS. Like any other application, you can find it by going into Finder, navigating to the Applications
folder, and then into the Utilities
folder. From here, double-click the Terminal application to open it up. Alternatively, you can use Spotlight by holding down the COMMAND
key and pressing SPACE
to find Terminal by typing it out in the box that appears.
To get more comfortable using the command line, take a look at An Introduction to the Linux Terminal. The command line interface on macOS is very similar, and the concepts in that tutorial are directly applicable.
Now that you have the Terminal running, let’s install some additional tools that Homebrew needs.
Step 2 — Installing Xcode’s Command Line Tools
Xcode is an integrated development environment (IDE) that is comprised of software development tools for macOS. You won’t need Xcode to use Homebrew, but some of the software and components you’ll want to install will rely on Xcode’s Command Line Tools package.
Execute the following command in the Terminal to download and install these components:
xcode-select --install
You’ll be prompted to start the installation, and then prompted again to accept a software license. Then the tools will download and install automatically.
You can now install Homebrew.
Step 3 — Installing and Setting Up Homebrew
To install Homebrew, you’ll download an installation script and then execute the script.
First, download the script to your local machine by typing the following command in your Terminal window:
curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/master/install.sh
The command uses curl
to download the Homebrew installation script from Homebrew’s Git repository on GitHub.
Let’s walk through the flags that are associated with the curl
command:
- The –
f
or--fail
flag tells the Terminal window to give no HTML document output on server errors. - The
-s
or--silent
flag mutescurl
so that it does not show the progress meter, and combined with the-S
or--show-error
flag it will ensure thatcurl
shows an error message if it fails. - The
-L
or--location
flag will tellcurl
to handle redirects. If the server reports that the requested page has moved to a different location, it’ll automatically execute the request again using the new location. - The
-o
switch specifies a local filename for the file.
Before running a script you’ve download from the Internet, you should review its contents so you know what the script will do. Use the less
command to look at the installation script:
less install.sh
Once you’re comfortable with the contents of the script, execute the script with the bash
command:
/bin/bash install.sh
The installation script will explain what it will do and will prompt you to confirm that you want to do it. This lets you know exactly what Homebrew is going to do to your system before you let it proceed. It also ensures you have the prerequisites in place before it continues.
You’ll be prompted to enter your password during the process. However, when you type your password, your keystrokes will not display in the Terminal window. This is a security measure and is something you’ll see often when prompted for passwords on the command line. Even though you don’t see them, your keystrokes are being recorded by the system, so press the RETURN
key once you’ve entered your password.
Press the letter y
for “yes” whenever you are prompted to confirm the installation.
Once the installation process is complete, you will want to put the directory Homebrew uses to store its executables at the front of the PATH
environment variable. This ensures that Homebrew installations will be called over the tools that macOS includes.
The file you’ll modify depends on which shell you’re using. If you’re using Bash, you’ll use the file ~/.bash_profile
:
nano ~/.bash_profile
However, if you’re using ZSH, you’ll open the file ~/.zshrc
.
nano ~/.zshrc
Once the file opens up in the Terminal window, add the following lines to the end of the file:
~/.bash_profile
# Add Homebrew's executable directory to the front of the PATH
export PATH=/usr/local/bin:$PATH
The first line is a comment that will help you remember what this does if you open this file in the future.
To save your changes, hold down the CTRL
key and the letter O
, and when prompted, press the RETURN
key. Then exit the editor by holding the CTRL
key and pressing X
. This will return you to your Terminal prompt.
To activate these changes, close and reopen your Terminal app. Alternatively, use the source
command to load the file you modified.
If you modified .bash_profile
, execute this command:
source ~/.bash_profile
If you modified .zshrc
, execute this command:
source ~/.zshrc
Once you have done this, the changes you have made to the PATH
environment variable will take effect. They’ll be set correctly when you log in again in the future, as the configuration file for your shell is executed automatically when you open the Terminal app.
Now let’s verify that Homebrew is set up correctly. Execute this command:
brew doctor
If no updates are required at this time, you’ll see this in your Terminal:
OutputYour system is ready to brew.
Otherwise, you may get a warning to run another command such as brew update
to ensure that your installation of Homebrew is up to date. Follow any on-screen instructions to fix your environment before moving on.
Step 4 — Installing, Upgrading, and Removing Packages
Now that Homebrew is installed, use it to download a package. The tree
command lets you see a graphical directory tree and is available via Homebrew.
Install tree
with the brew install
command:
brew install tree
Homebrew will update its list of packages and then download and install the tree
command:
Output
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/tree-1.8.0.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring tree-1.8.0.catalina.bottle.tar.gz
🍺 /usr/local/Cellar/tree/1.8.0: 8 files, 117.2KB
Homebrew installs files to /usr/local
by default, so they won’t interfere with future macOS updates. Verify that tree
is installed by displaying the command’s location with the which
command:
which tree
The output shows that tree
is located in /usr/local/bin
:
Output/usr/local/bin/tree
Run the tree
command to see the version:
tree --version
The version prints to the screen, indicating it’s installed:
Outputtree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
Occasionally, you’ll want to upgrade an existing package. Use the brew upgrade
command, followed by the package name:
brew upgrade tree
You can run brew upgrade
with no additional arguments to upgrade all programs and packages Homebrew manages.
When you install a new version, Homebrew keeps the older version around. After a while, you might want to reclaim disk space by removing these older copies. Run brew cleanup
to remove all old versions of your Homebrew-managed software.
To remove a package you’re no longer using, use brew uninstall
. To uninstall the tree
command, execute this command:
brew uninstall tree
The output shows that the package was removed:
OutputUninstalling /usr/local/Cellar/tree/1.8.0... (8 files, 117.2KB)
You can use Homebrew to install desktop applications too.
Step 5 — Installing Desktop Applications
You’re not restricted to using Homebrew for command-line tools. Homebrew Cask lets you install desktop applications. This feature is included with Homebrew, so there’s nothing additional to install.
To use Homebrew to install Visual Studio Code, execute the following command:
brew cask install visual-studio-code
The application will install:
OutputUpdating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
abstract cacher chirp sipgate-softphone
==> Downloading https://update.code.visualstudio.com/1.48.2/darwin/stable
==> Downloading from https://az764295.vo.msecnd.net/stable/a0479759d6e9ea56afa657e454193f72aef85bd0/VSC
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'visual-studio-code'.
==> Installing Cask visual-studio-code
==> Moving App 'Visual Studio Code.app' to '/Applications/Visual Studio Code.app'.
==> Linking Binary 'code' to '/usr/local/bin/code'.
🍺 visual-studio-code was successfully installed!
You’ll find the application in your Applications
folder, just as if you’d installed it manually.
To remove it, use brew cask uninstall
:
brew cask uninstall visual-studio-code
Homebrew will remove the installed software:
Output==> Uninstalling Cask visual-studio-code
==> Backing App 'Visual Studio Code.app' up to '/usr/local/Caskroom/visual-studio-code/1.48.2/Visual St
==> Removing App '/Applications/Visual Studio Code.app'.
==> Unlinking Binary '/usr/local/bin/code'.
==> Purging files for version 1.48.2 of Cask visual-studio-code
It performs a backup first in case the removal fails, but once the program is fully uninstalled, the backup is removed as well.
Step 6 — Uninstalling Homebrew
If you no longer need Homebrew, you can use its uninstall script.
Download the uninstall script with curl
:
curl -fsSL -o uninstall.sh https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh
As always, review the contents of the script with the less
command to verify the script’s contents:
less uninstall.sh
Once you’ve verified the script, execute the script with the --help
flag to see the various options you can use:
bash uninstall.sh --help
The options display on the screen:
OutputHomebrew Uninstaller
Usage: uninstall.sh [options]
-p, --path=PATH Sets Homebrew prefix. Defaults to /usr/local.
--skip-cache-and-logs
Skips removal of HOMEBREW_CACHE and HOMEBREW_LOGS.
-f, --force Uninstall without prompting.
-q, --quiet Suppress all output.
-d, --dry-run Simulate uninstall but don't remove anything.
-h, --help Display this message.
Use the -d
flag to see what the script will do:
bash uninstall.sh -d
The script will list everything it will delete:
OutputWarning: This script would remove:
/Users/brianhogan/Library/Caches/Homebrew/
/Users/brianhogan/Library/Logs/Homebrew/
/usr/local/Caskroom/
/usr/local/Cellar/
/usr/local/bin/brew -> /usr/local/bin/brew
==> Removing Homebrew installation...
Would delete:
....
When you’re ready to remove everything, execute the script without any flags:
bash uninstall.sh
This removes Homebrew and any programs you’ve installed with it.
Conclusion
In this tutorial you installed and used Homebrew on your Mac. You can now use Homebrew to install command line tools, programming languages, and other utilities you’ll need for software development.
Homebrew has many packages you can install. Visit the official list to search for your favorite programs.
brew(1) – The Missing Package Manager for macOS (or Linux)
https://docs.brew.sh/Manpage
SYNOPSIS
brew
--version
brew
command
[--verbose
|-v
] [options
] [formula
] …
DESCRIPTION
Homebrew is the easiest and most flexible way to install the UNIX tools Apple didn’t include with macOS. It can also install software not packaged for your Linux distribution to your home directory without requiring sudo
.
ESSENTIAL COMMANDS
For the full command list, see the COMMANDS section.
With --verbose
or --debug
, many commands print extra debugging information. Note that these options should only appear after a command.
install
formula
Install formula
.
formula
is usually the name of the formula to install, but it has other syntaxes which are listed in the SPECIFYING FORMULAE section.
uninstall
formula
Uninstall formula
.
list
List all installed formulae.
search
[text
|/
text
/
]
Perform a substring search of cask tokens and formula names for text
. If text
is flanked by slashes, it is interpreted as a regular expression. The search for text
is extended online to homebrew/core
and homebrew/cask
. If no search term is provided, all locally available formulae are listed.
COMMANDS
analytics
[subcommand
]
Control Homebrew’s anonymous aggregate user behaviour analytics. Read more at https://docs.brew.sh/Analytics.
brew analytics
[state
]
Display the current state of Homebrew’s analytics.
brew analytics
(on
|off
)
Turn Homebrew’s analytics on or off respectively.
brew analytics regenerate-uuid
Regenerate the UUID used for Homebrew’s analytics.
autoremove
[options
]
Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.
-n
,--dry-run
: List what would be uninstalled, but do not actually uninstall anything.
cask
command
[options
] [cask
]
Homebrew Cask provides a friendly CLI workflow for the administration of macOS applications distributed as binaries.
Commands:
--cache
Display the file used to cache acask
.audit
Checkcask
for Homebrew coding style violations.cat
Dump raw source of acask
to the standard output.create
Creates the givencask
and opens it in an editor.doctor
Checks for configuration issues.edit
Open the givencask
for editing.fetch
Downloads remote application files to local cache.help
Print help forcask
commands.home
Opens the homepage of the givencask
.info
Displays information about the givencask
.install
Installs the givencask
.list
Lists installed casks or the casks provided in the arguments.outdated
List the outdated installed casks.reinstall
Reinstalls the givencask
.style
Checks style of the givencask
using RuboCop.uninstall
Uninstalls the givencask
.upgrade
Upgrades all outdated casks or the specified casks.zap
Zaps all files associated with the givencask
.
See also: man brew
cleanup
[options
] [formula
|cask
]
Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae. If arguments are specified, only do this for the given formulae and casks. Removes all downloads more than 120 days old. This can be adjusted with HOMEBREW_CLEANUP_MAX_AGE_DAYS
.
--prune
: Remove all cache files older than specifieddays
.-n
,--dry-run
: Show what would be removed, but do not actually remove anything.-s
: Scrub the cache, including downloads for even the latest versions. Note downloads for any installed formulae or casks will still not be deleted. If you want to delete those too:rm -rf "$(brew --cache)"
--prune-prefix
: Only prune the symlinks and directories from the prefix and remove no other files.
commands
[options
]
Show lists of built-in and external commands.
-q
,--quiet
: List only the names of commands without category headers.--include-aliases
: Include aliases of internal commands.
config
Show Homebrew and system configuration info useful for debugging. If you file a bug report, you will be required to provide this information.
deps
[options
] [formula
]
Show dependencies for formula
. Additional options specific to formula
may be appended to the command. When given multiple formula arguments, show the intersection of dependencies for each formula.
-n
: Sort dependencies in topological order.--1
: Only show dependencies one level down, instead of recursing.--union
: Show the union of dependencies for multipleformula
, instead of the intersection.--full-name
: List dependencies by their full name.--include-build
: Include:build
dependencies forformula
.--include-optional
: Include:optional
dependencies forformula
.--include-test
: Include:test
dependencies forformula
(non-recursive).--skip-recommended
: Skip:recommended
dependencies forformula
.--include-requirements
: Include requirements in addition to dependencies forformula
.--tree
: Show dependencies as a tree. When given multiple formula arguments, show individual trees for each formula.--annotate
: Mark any build, test, optional, or recommended dependencies as such in the output.--installed
: List dependencies for formulae that are currently installed. Ifformula
is specified, list only its dependencies that are currently installed.--all
: List dependencies for all available formulae.--for-each
: Switch into the mode used by the--all
option, but only list dependencies for each providedformula
, one formula per line. This is used for debugging the--installed
/--all
display mode.
desc
[options
] (text
|/
text
/
|formula
)
Display formula
’s name and one-line description. Formula descriptions are cached; the cache is created on the first search, making that search slower than subsequent ones.
-s
,--search
: Search both names and descriptions fortext
. Iftext
is flanked by slashes, it is interpreted as a regular expression.-n
,--name
: Search just names fortext
. Iftext
is flanked by slashes, it is interpreted as a regular expression.-d
,--description
: Search just descriptions fortext
. Iftext
is flanked by slashes, it is interpreted as a regular expression.
doctor
[options
]
Check your system for potential problems. Will exit with a non-zero status if any potential problems are found. Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don’t worry or file an issue; just ignore this.
--list-checks
: List all audit methods, which can be run individually if provided as arguments.-D
,--audit-debug
: Enable debugging and profiling of audit methods.
fetch
[options
] formula
Download a bottle (if available) or source packages for formula
. For tarballs, also print SHA-256 checksums.
--HEAD
: Fetch HEAD version instead of stable version.--devel
: Fetch development version instead of stable version.-f
,--force
: Remove a previously cached version and re-fetch.-v
,--verbose
: Do a verbose VCS checkout, if the URL represents a VCS. This is useful for seeing if an existing VCS cache has been updated.--retry
: Retry if downloading fails or re-download if the checksum of a previously cached version no longer matches.--deps
: Also download dependencies for any listedformula
.-s
,--build-from-source
: Download source packages rather than a bottle.--build-bottle
: Download source packages (for eventual bottling) rather than a bottle.--force-bottle
: Download a bottle if it exists for the current or newest version of macOS, even if it would not be used during installation.
gist-logs
[options
] formula
Upload logs for a failed build of formula
to a new Gist. Presents an error message if no logs are found.
--with-hostname
: Include the hostname in the Gist.-n
,--new-issue
: Automatically create a new issue in the appropriate GitHub repository after creating the Gist.-p
,--private
: The Gist will be marked private and will not appear in listings but will be accessible with its link.
home
[formula
]
Open formula
’s homepage in a browser, or open Homebrew’s own homepage if no formula is provided.
info
[options
] [formula
]
Display brief statistics for your Homebrew installation.
If formula
is provided, show summary of information about formula
.
--analytics
: List global Homebrew analytics data or, if specified, installation and build error data forformula
(provided neitherHOMEBREW_NO_ANALYTICS
norHOMEBREW_NO_GITHUB_API
are set).--days
: How many days of analytics data to retrieve. The value fordays
must be30
,90
or365
. The default is30
.--category
: Which type of analytics data to retrieve. The value forcategory
must beinstall
,install-on-request
orbuild-error
;cask-install
oros-version
may be specified ifformula
is not. The default isinstall
.--github
: Open the GitHub source page forformula
in a browser. To view formula history locally:brew log -p
formula
--json
: Print a JSON representation offormula
. Currently the default and only accepted value forversion
isv1
. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew--installed
: Print JSON of formulae that are currently installed.--all
: Print JSON of all available formulae.-v
,--verbose
: Show more verbose analytics data forformula
.
install
[options
] formula
|cask
Install a formula
or cask
. Additional options specific to a formula
may be appended to the command.
Unless HOMEBREW_NO_INSTALL_CLEANUP
is set, brew cleanup
will then be run for the installed formulae or, every 30 days, for all formulae.
-d
,--debug
: If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory.-f
,--force
: Install formulae without checking for previously installed keg-only or non-migrated versions. Overwrite existing files when installing casks.-v
,--verbose
: Print the verification and postinstall steps.--formula
: Treat all named arguments as formulae.--env
: Ifstd
is passed, use the standard build environment instead of superenv. Ifsuper
is passed, use superenv even if the formula specifies the standard build environment.--ignore-dependencies
: An unsupported Homebrew development flag to skip installing any dependencies of any kind. If the dependencies are not already present, the formula will have issues. If you’re not developing Homebrew, consider adjusting your PATH rather than using this flag.--only-dependencies
: Install the dependencies with specified options but do not install the formula itself.--cc
: Attempt to compile using the specifiedcompiler
, which should be the name of the compiler’s executable, e.g.gcc-7
for GCC 7. In order to use LLVM’s clang, specifyllvm_clang
. To use the Apple-provided clang, specifyclang
. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option.-s
,--build-from-source
: Compileformula
from source even if a bottle is provided. Dependencies will still be installed from bottles if they are available.--force-bottle
: Install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation.--include-test
: Install testing dependencies required to runbrew test
formula
.--HEAD
: Ifformula
defines it, install the HEAD version, aka. master, trunk, unstable.--fetch-HEAD
: Fetch the upstream repository to detect if the HEAD installation of the formula is outdated. Otherwise, the repository’s HEAD will only be checked for updates when a new stable or development version has been released.--keep-tmp
: Retain the temporary files created during installation.--build-bottle
: Prepare the formula for eventual bottling during installation, skipping any post-install steps.--bottle-arch
: Optimise bottles for the specified architecture rather than the oldest architecture supported by the version of macOS the bottles are built on.--display-times
: Print install times for each formula at the end of the run.-i
,--interactive
: Download and patchformula
, then open a shell. This allows the user to run./configure --help
and otherwise determine how to turn the software package into a Homebrew package.-g
,--git
: Create a Git repository, useful for creating patches to the software.--cask
: Treat all named arguments as casks.--[no-]binaries
: Disable/enable linking of helper executables (default: enabled).--require-sha
: Require all casks to have a checksum.--[no-]quarantine
: Disable/enable quarantining of downloads (default: enabled).--skip-cask-deps
: Skip installing cask dependencies.
leaves
List installed formulae that are not dependencies of another installed formula.
link
, ln
[options
] formula
Symlink all of formula
’s installed files into Homebrew’s prefix. This is done automatically when you install formulae but can be useful for DIY installations.
--overwrite
: Delete files that already exist in the prefix while linking.-n
,--dry-run
: List files which would be linked or deleted bybrew link --overwrite
without actually linking or deleting any files.-f
,--force
: Allow keg-only formulae to be linked.
list
, ls
[options
] [formula
|cask
]
List all installed formulae and casks.
If formula
is provided, summarise the paths within its current keg.
--formula
: List only formulae. This is the default when output is not to a terminal.--cask
: List only casks, orcask
if provided.--unbrewed
: List files in Homebrew’s prefix not installed by Homebrew.--full-name
: Print formulae with fully-qualified names. If--full-name
is not passed, other options (i.e.-1
,-l
,-r
and-t
) are passed tols
(1) which produces the actual output.--versions
: Show the version number for installed formulae, or only the specified formulae ifformula
are provided.--multiple
: Only show formulae with multiple versions installed.--pinned
: Show the versions of pinned formulae, or only the specified (pinned) formulae ifformula
are provided. See alsopin
,unpin
.-1
: Force output to be one entry per line. This is the default when output is not to a terminal.-l
: List formulae in long format. If the output is to a terminal, a total sum for all the file sizes is printed before the long listing.-r
: Reverse the order of the formulae sort to list the oldest entries first.-t
: Sort formulae by time modified, listing most recently modified first.
log
[options
] [formula
]
Show the git log
for formula
, or show the log for the Homebrew repository if no formula is provided.
-p
,--patch
: Also print patch from commit.--stat
: Also print diffstat from commit.--oneline
: Print only one line per commit.-1
: Print only one commit.-n
,--max-count
: Print only a specified number of commits.
migrate
[options
] formula
Migrate renamed packages to new names, where formula
are old names of packages.
-f
,--force
: Treat installedformula
and providedformula
as if they are from the same taps and migrate them anyway.
missing
[options
] [formula
]
Check the given formula
kegs for missing dependencies. If no formula
are provided, check all kegs. Will exit with a non-zero status if any kegs are found to be missing dependencies.
--hide
: Act as if none of the specifiedhidden
are installed.hidden
should be a comma-separated list of formulae.
options
[options
] [formula
]
Show install options specific to formula
.
--compact
: Show all options on a single line separated by spaces.--installed
: Show options for formulae that are currently installed.--all
: Show options for all available formulae.--command
: Show options for the specifiedcommand
.
outdated
[options
] [formula
|cask
]
List installed casks and formulae that have an updated version available. By default, version information is displayed in interactive shells, and suppressed otherwise.
-q
,--quiet
: List only the names of outdated kegs (takes precedence over--verbose
).-v
,--verbose
: Include detailed version information.--formula
: List only outdated formulae.--cask
: List only outdated casks.--json
: Print output in JSON format. There are two versions: v1 and v2. v1 is deprecated and is currently the default if no version is specified. v2 prints outdated formulae and casks.--fetch-HEAD
: Fetch the upstream repository to detect if the HEAD installation of the formula is outdated. Otherwise, the repository’s HEAD will only be checked for updates when a new stable or development version has been released.--greedy
: Print outdated casks withauto_updates
orversion :latest
.
pin
formula
Pin the specified formula
, preventing them from being upgraded when issuing the brew upgrade
formula
command. See also unpin
.
postinstall
formula
Rerun the post-install steps for formula
.
readall
[options
] [tap
]
Import all items from the specified tap
, or from all installed taps if none is provided. This can be useful for debugging issues across all items when making significant changes to formula.rb
, testing the performance of loading all items or checking if any current formulae/casks have Ruby issues.
--aliases
: Verify any alias symlinks in each tap.--syntax
: Syntax-check all of Homebrew’s Ruby files (if no*
tap*
is passed).
reinstall
[options
] formula
|cask
Uninstall and then reinstall a formula
or cask
using the same options it was originally installed with, plus any appended options specific to a formula
.
Unless HOMEBREW_NO_INSTALL_CLEANUP
is set, brew cleanup
will then be run for the reinstalled formulae or, every 30 days, for all formulae.
-d
,--debug
: If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory.-f
,--force
: Install without checking for previously installed keg-only or non-migrated versions.-v
,--verbose
: Print the verification and postinstall steps.--formula
: Treat all named arguments as formulae.-s
,--build-from-source
: Compileformula
from source even if a bottle is available.-i
,--interactive
: Download and patchformula
, then open a shell. This allows the user to run./configure --help
and otherwise determine how to turn the software package into a Homebrew package.--force-bottle
: Install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation.--keep-tmp
: Retain the temporary files created during installation.--display-times
: Print install times for each formula at the end of the run.--cask
: Treat all named arguments as casks.--[no-]binaries
: Disable/enable linking of helper executables (default: enabled).--require-sha
: Require all casks to have a checksum.--[no-]quarantine
: Disable/enable quarantining of downloads (default: enabled).--skip-cask-deps
: Skip installing cask dependencies.
search
[options
] [text
|/
text
/
]
Perform a substring search of cask tokens and formula names for text
. If text
is flanked by slashes, it is interpreted as a regular expression. The search for text
is extended online to homebrew/core
and homebrew/cask
.
If no text
is provided, list all locally available formulae (including tapped ones). No online search is performed.
--formula
: Withouttext
, list all locally available formulae (no online search is performed). Withtext
, search online and locally for formulae.--cask
: Withouttext
, list all locally available casks (including tapped ones, no online search is performed). Withtext
, search online and locally for casks.--desc
: Search for formulae with a description matchingtext
and casks with a name matchingtext
.--pull-request
: Search for GitHub pull requests containingtext
.--macports
: Search fortext
in the given package manager’s list.--fink
: Search fortext
in the given package manager’s list.--opensuse
: Search fortext
in the given package manager’s list.--fedora
: Search fortext
in the given package manager’s list.--debian
: Search fortext
in the given package manager’s list.--ubuntu
: Search fortext
in the given package manager’s list.
shellenv
Print export statements. When run in a shell, this installation of Homebrew will be added to your PATH
, MANPATH
, and INFOPATH
.
The variables HOMEBREW_PREFIX
, HOMEBREW_CELLAR
and HOMEBREW_REPOSITORY
are also exported to avoid querying them multiple times. Consider adding evaluation of this command’s output to your dotfiles (e.g. ~/.profile
, ~/.bash_profile
, or ~/.zprofile
) with: eval $(brew shellenv)
tap
[options
] [user
/
repo
] [URL
]
Tap a formula repository.
If no arguments are provided, list all installed taps.
With URL
unspecified, tap a formula repository from GitHub using HTTPS. Since so many taps are hosted on GitHub, this command is a shortcut for brew tap
user
/
repo
https://github.com/
user
/homebrew-
repo
.
With URL
specified, tap a formula repository from anywhere, using any transport protocol that git
(1) handles. The one-argument form of tap
simplifies but also limits. This two-argument command makes no assumptions, so taps can be cloned from places other than GitHub and using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync.
--full
: Convert a shallow clone to a full clone without untapping. Taps are only cloned as shallow clones if--shallow
was originally passed.--shallow
: Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration.--force-auto-update
: Auto-update tap even if it is not hosted on GitHub. By default, only taps hosted on GitHub are auto-updated (for performance reasons).--repair
: Migrate tapped formulae from symlink-based to directory-based structure.--list-pinned
: List all pinned taps.
tap-info
[options
] [tap
]
Show detailed information about one or more tap
s.
If no tap
names are provided, display brief statistics for all installed taps.
--installed
: Show information on each installed tap.--json
: Print a JSON representation oftap
. Currently the default and only accepted value forversion
isv1
. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew
uninstall
, rm
, remove
[options
] formula
Uninstall formula
.
-f
,--force
: Delete all installed versions offormula
.--ignore-dependencies
: Don’t fail uninstall, even ifformula
is a dependency of any installed formulae.
unlink
[options
] formula
Remove symlinks for formula
from Homebrew’s prefix. This can be useful for temporarily disabling a formula: brew unlink
formula
&&
commands
&& brew link
formula
-n
,--dry-run
: List files which would be unlinked without actually unlinking or deleting any files.
unpin
formula
Unpin formula
, allowing them to be upgraded by brew upgrade
formula
. See also pin
.
untap
tap
Remove a tapped formula repository.
update
[options
]
Fetch the newest version of Homebrew and all formulae from GitHub using git
(1) and perform any necessary migrations.
--merge
: Usegit merge
to apply updates (rather thangit rebase
).--preinstall
: Run on auto-updates (e.g. beforebrew install
). Skips some slower steps.-f
,--force
: Always do a slower, full update check (even if unnecessary).
update-reset
[repository
]
Fetch and reset Homebrew and all tap repositories (or any specified repository
) using git
(1) to their latest origin/master
.
Note: this will destroy all your uncommitted or committed changes.
upgrade
[options
] [formula
|cask
]
Upgrade outdated casks and outdated, unpinned formulae using the same options they were originally installed with, plus any appended brew formula options. If cask
or formula
are specified, upgrade only the given cask
or formula
kegs (unless they are pinned; see pin
, unpin
).
Unless HOMEBREW_NO_INSTALL_CLEANUP
is set, brew cleanup
will then be run for the upgraded formulae or, every 30 days, for all formulae.
-d
,--debug
: If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory.-f
,--force
: Install formulae without checking for previously installed keg-only or non-migrated versions. Overwrite existing files when installing casks.-v
,--verbose
: Print the verification and postinstall steps.-n
,--dry-run
: Show what would be upgraded, but do not actually upgrade anything.--formula
: Treat all named arguments as formulae. If no named argumentsare specified, upgrade only outdated formulae.-s
,--build-from-source
: Compileformula
from source even if a bottle is available.-i
,--interactive
: Download and patchformula
, then open a shell. This allows the user to run./configure --help
and otherwise determine how to turn the software package into a Homebrew package.--force-bottle
: Install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation.--fetch-HEAD
: Fetch the upstream repository to detect if the HEAD installation of the formula is outdated. Otherwise, the repository’s HEAD will only be checked for updates when a new stable or development version has been released.--ignore-pinned
: Set a successful exit status even if pinned formulae are not upgraded.--keep-tmp
: Retain the temporary files created during installation.--display-times
: Print install times for each formula at the end of the run.--cask
: Treat all named arguments as casks. If no named arguments are specified, upgrade only outdated casks.--[no-]binaries
: Disable/enable linking of helper executables (default: enabled).--require-sha
: Require all casks to have a checksum.--[no-]quarantine
: Disable/enable quarantining of downloads (default: enabled).--skip-cask-deps
: Skip installing cask dependencies.--greedy
: Also include casks withauto_updates true
orversion :latest
.
uses
[options
] formula
Show formulae that specify formula
as a dependency (i.e. show dependents of formula
). When given multiple formula arguments, show the intersection of formulae that use formula
. By default, uses
shows all formulae that specify formula
as a required or recommended dependency for their stable builds.
--recursive
: Resolve more than one level of dependencies.--installed
: Only list formulae that are currently installed.--include-build
: Include all formulae that specifyformula
as:build
type dependency.--include-test
: Include all formulae that specifyformula
as:test
type dependency.--include-optional
: Include all formulae that specifyformula
as:optional
type dependency.--skip-recommended
: Skip all formulae that specifyformula
as:recommended
type dependency.
--cache
[options
] [formula
|cask
]
Display Homebrew’s download cache. See also HOMEBREW_CACHE
.
If formula
is provided, display the file or directory used to cache formula
.
-s
,--build-from-source
: Show the cache file used when building from source.--force-bottle
: Show the cache file used when pouring a bottle.--formula
: Only show cache files for formulae.--cask
: Only show cache files for casks.
--caskroom
[cask
]
Display Homebrew’s Caskroom path.
If cask
is provided, display the location in the Caskroom where cask
would be installed, without any sort of versioned directory as the last path.
--cellar
[formula
]
Display Homebrew’s Cellar path. Default: $(brew --prefix)/Cellar
, or if that directory doesn’t exist, $(brew --repository)/Cellar
.
If formula
is provided, display the location in the Cellar where formula
would be installed, without any sort of versioned directory as the last path.
--env
[options
] [formula
]
Summarise Homebrew’s build environment as a plain list.
If the command’s output is sent through a pipe and no shell is specified, the list is formatted for export to bash
(1) unless --plain
is passed.
--shell
: Generate a list of environment variables for the specified shell, or--shell=auto
to detect the current shell.--plain
: Generate plain output even when piped.
--prefix
[formula
]
Display Homebrew’s install path. Default: /usr/local
on macOS and /home/linuxbrew/.linuxbrew
on Linux.
If formula
is provided, display the location in the Cellar where formula
is or would be installed.
--repository
, --repo
[user
/
repo
]
Display where Homebrew’s .git
directory is located.
If user
/
repo
are provided, display where tap user
/
repo
’s directory is located.
--version
Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask (if tapped) to standard output.
DEVELOPER COMMANDS
audit
[options
] [formula
]
Check formula
for Homebrew coding style violations. This should be run before submitting a new formula. If no formula
are provided, check all locally available formulae and skip style checks. Will exit with a non-zero status if any errors are found.
--strict
: Run additional, stricter style checks.--git
: Run additional, slower style checks that navigate the Git repository.--online
: Run additional, slower style checks that require a network connection.--new-formula
: Run various additional style checks to determine if a new formula is eligible for Homebrew. This should be used when creating new formula and implies--strict
and--online
.--tap
: Check the formulae within the given tap, specified asuser
/
repo
.--fix
: Fix style violations automatically using RuboCop’s auto-correct feature.--display-cop-names
: Include the RuboCop cop name for each violation in the output.--display-filename
: Prefix every line of output with the file or formula name being audited, to make output easy to grep.--skip-style
: Skip running non-RuboCop style checks. Useful if you plan on runningbrew style
separately. Enabled by default unless a formula is specified by name.-D
,--audit-debug
: Enable debugging and profiling of audit methods.--only
: Specify a comma-separatedmethod
list to only run the methods namedaudit_
method
.--except
: Specify a comma-separatedmethod
list to skip running the methods namedaudit_
method
.--only-cops
: Specify a comma-separatedcops
list to check for violations of only the listed RuboCop cops.--except-cops
: Specify a comma-separatedcops
list to skip checking for violations of the listed RuboCop cops.
bottle
[options
] formula
Generate a bottle (binary package) from a formula that was installed with --build-bottle
. If the formula specifies a rebuild version, it will be incremented in the generated DSL. Passing --keep-old
will attempt to keep it at its original value, while --no-rebuild
will remove it.
--skip-relocation
: Do not check if the bottle can be marked as relocatable.--force-core-tap
: Build a bottle even ifformula
is not inhomebrew/core
or any installed taps.--no-rebuild
: If the formula specifies a rebuild version, remove it from the generated DSL.--keep-old
: If the formula specifies a rebuild version, attempt to preserve its value in the generated DSL.--json
: Write bottle information to a JSON file, which can be used as the value for--merge
.--merge
: Generate an updated bottle block for a formula and optionally merge it into the formula file. Instead of a formula name, requires the path to a JSON file generated withbrew bottle --json
formula
.--write
: Write changes to the formula file. A new commit will be generated unless--no-commit
is passed.--no-commit
: When passed with--write
, a new commit will not generated after writing changes to the formula file.--root-url
: Use the specifiedURL
as the root of the bottle’s URL instead of Homebrew’s default.
bump
[options
] [formula
]
Display out-of-date brew formulae and the latest version available. Also displays whether a pull request has been opened with the URL.
--limit
: Limit number of package results returned.
bump-cask-pr
[options
] cask
Create a pull request to update cask
with a new version.
A best effort to determine the SHA-256
will be made if the value is not supplied by the user.
-n
,--dry-run
: Print what would be done rather than doing it.--write
: Make the expected file modifications without taking any Git actions.--commit
: When passed with--write
, generate a new commit after writing changes to the cask file.--no-audit
: Don’t runbrew cask audit
before opening the PR.--online
: Runbrew cask audit --online
before opening the PR.--no-style
: Don’t runbrew cask style --fix
before opening the PR.--no-browse
: Print the pull request URL instead of opening in a browser.--no-fork
: Don’t try to fork the repository.--version
: Specify the newversion
for the cask.--message
: Appendmessage
to the default pull request message.--url
: Specify theURL
for the new download.--sha256
: Specify theSHA-256
checksum of the new download.-f
,--force
: Ignore duplicate open PRs.
bump-formula-pr
[options
] [formula
]
Create a pull request to update formula
with a new URL or a new tag.
If a URL
is specified, the SHA-256
checksum of the new download should also be specified. A best effort to determine the SHA-256
and formula
name will be made if either or both values are not supplied by the user.
If a tag
is specified, the Git commit revision
corresponding to that tag should also be specified. A best effort to determine the revision
will be made if the value is not supplied by the user.
If a version
is specified, a best effort to determine the URL
and SHA-256
or the tag
and revision
will be made if both values are not supplied by the user.
Note: this command cannot be used to transition a formula from a URL-and-SHA-256 style specification into a tag-and-revision style specification, nor vice versa. It must use whichever style specification the formula already uses.
-n
,--dry-run
: Print what would be done rather than doing it.--write
: Make the expected file modifications without taking any Git actions.--commit
: When passed with--write
, generate a new commit after writing changes to the formula file.--no-audit
: Don’t runbrew audit
before opening the PR.--strict
: Runbrew audit --strict
before opening the PR.--online
: Runbrew audit --online
before opening the PR.--no-browse
: Print the pull request URL instead of opening in a browser.--no-fork
: Don’t try to fork the repository.--mirror
: Use the specifiedURL
as a mirror URL. IfURL
is a comma-separated list of URLs, multiple mirrors will be added.--version
: Use the specifiedversion
to override the value parsed from the URL or tag. Note that--version=0
can be used to delete an existing version override from a formula if it has become redundant.--message
: Appendmessage
to the default pull request message.--url
: Specify theURL
for the new download. If aURL
is specified, theSHA-256
checksum of the new download should also be specified.--sha256
: Specify theSHA-256
checksum of the new download.--tag
: Specify the new git committag
for the formula.--revision
: Specify the new git commitrevision
corresponding to the specifiedtag
.-f
,--force
: Ignore duplicate open PRs. Remove all mirrors if--mirror
was not specified.
bump-revision
[options
] formula
[formula
…]
Create a commit to increment the revision of formula
. If no revision is present, “revision 1” will be added.
-n
,--dry-run
: Print what would be done rather than doing it.--message
: Appendmessage
to the default commit message.
cat
formula
Display the source of formula
.
command
cmd
Display the path to the file being used when invoking brew
cmd
.
create
[options
] URL
Generate a formula for the downloadable file at URL
and open it in the editor. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you’ll have to make your own template. The wget
formula serves as a simple example. For the complete API, see: https://rubydoc.brew.sh/Formula
--autotools
: Create a basic template for an Autotools-style build.--cmake
: Create a basic template for a CMake-style build.--crystal
: Create a basic template for a Crystal build.--go
: Create a basic template for a Go build.--meson
: Create a basic template for a Meson-style build.--node
: Create a basic template for a Node build.--perl
: Create a basic template for a Perl build.--python
: Create a basic template for a Python build.--ruby
: Create a basic template for a Ruby build.--rust
: Create a basic template for a Rust build.--no-fetch
: Homebrew will not downloadURL
to the cache and will thus not add its SHA-256 to the formula for you, nor will it check the GitHub API for GitHub projects (to fill out its description and homepage).--HEAD
: Indicate thatURL
points to the package’s repository rather than a file.--set-name
: Explicitly set thename
of the new formula.--set-version
: Explicitly set theversion
of the new formula.--set-license
: Explicitly set thelicense
of the new formula.--tap
: Generate the new formula within the given tap, specified asuser
/
repo
.-f
,--force
: Ignore errors for disallowed formula names and names that shadow aliases.
dispatch-build-bottle
[options
] formula
[formula
…]
Build bottles for these formulae with GitHub Actions.
--tap
: Target tap repository (default:homebrew/core
).--issue
: If specified, post a comment to this issue number if the job fails.--macos
: Version of macOS the bottle should be built for.--workflow
: Dispatch specified workflow (default:dispatch-build-bottle.yml
).--upload
: Upload built bottles to Bintray.
diy
[options
]
Automatically determine the installation prefix for non-Homebrew software. Using the output from this command, you can install your own software into the Cellar and then link it into Homebrew’s prefix with brew link
.
--name
: Explicitly set thename
of the package being installed.--version
: Explicitly set theversion
of the package being installed.
edit
[formula
]
Open formula
in the editor set by EDITOR
or HOMEBREW_EDITOR
, or open the Homebrew repository for editing if no formula is provided.
extract
[options
] formula
tap
Look through repository history to find the most recent version of formula
and create a copy in tap
/Formula/
formula
@
version
.rb
. If the tap is not installed yet, attempt to install/clone the tap before continuing. To extract a formula from a tap that is not homebrew/core
use its fully-qualified form of user
/
repo
/
formula
.
--version
: Extract the specifiedversion
offormula
instead of the most recent.-f
,--force
: Overwrite the destination formula if it already exists.
formula
formula
Display the path where formula
is located.
install-bundler-gems
Install Homebrew’s Bundler gems.
irb
[options
]
Enter the interactive Homebrew Ruby shell.
--examples
: Show several examples.--pry
: Use Pry instead of IRB. Implied ifHOMEBREW_PRY
is set.
linkage
[options
] [formula
]
Check the library links from the given formula
kegs. If no formula
are provided, check all kegs. Raises an error if run on uninstalled formulae.
--test
: Show only missing libraries and exit with a non-zero status if any missing libraries are found.--reverse
: For every library that a keg references, print its dylib path followed by the binaries that link to it.--cached
: Print the cached linkage values stored inHOMEBREW_CACHE
, set by a previousbrew linkage
run.
livecheck
[formulae
]
Check for newer versions of formulae from upstream.
If no formula argument is passed, the list of formulae to check is taken from HOMEBREW_LIVECHECK_WATCHLIST
or ~/.brew_livecheck_watchlist
.
--full-name
: Print formulae with fully-qualified names.--tap
: Check formulae within the given tap, specified asuser
/
repo
.--all
: Check all available formulae.--installed
: Check formulae that are currently installed.--newer-only
: Show the latest version only if it’s newer than the formula.--json
: Output information in JSON format.-q
,--quiet
: Suppress warnings, don’t print a progress bar for JSON output.
man
[options
]
Generate Homebrew’s manpages.
--fail-if-changed
: Return a failing status code if changes are detected in the manpage outputs. This can be used to notify CI when the manpages are out of date. Additionally, the date used in new manpages will match those in the existing manpages (to allow comparison without factoring in the date).--link
: This is now done automatically bybrew update
.
pr-automerge
[options
]
Find pull requests that can be automatically merged using brew pr-publish
.
--tap
: Target tap repository (default:homebrew/core
).--with-label
: Pull requests must have this label.--without-labels
: Pull requests must not have these labels (default:do not merge
,new formula
,automerge-skip
,linux-only
).--without-approval
: Pull requests do not require approval to be merged.--publish
: Runbrew pr-publish
on matching pull requests.--autosquash
: Instructbrew pr-publish
to automatically reformat and reword commits in the pull request to our preferred format.--ignore-failures
: Include pull requests that have failing status checks.
pr-publish
[options
] pull_request
[pull_request
…]
Publish bottles for a pull request with GitHub Actions. Requires write access to the repository.
--autosquash
: If supported on the target tap, automatically reformat and reword commits in the pull request to our preferred format.--message
: Message to include when autosquashing revision bumps, deletions, and rebuilds.--tap
: Target tap repository (default:homebrew/core
).--workflow
: Target workflow filename (default:publish-commit-bottles.yml
).
pr-pull
[options
] pull_request
[pull_request
…]
Download and publish bottles, and apply the bottle commit from a pull request with artifacts generated by GitHub Actions. Requires write access to the repository.
--no-publish
: Download the bottles, apply the bottle commit and upload the bottles to Bintray, but don’t publish them.--no-upload
: Download the bottles and apply the bottle commit, but don’t upload to Bintray or GitHub Releases.-n
,--dry-run
: Print what would be done rather than doing it.--clean
: Do not amend the commits from pull requests.--keep-old
: If the formula specifies a rebuild version, attempt to preserve its value in the generated DSL.--autosquash
: Automatically reformat and reword commits in the pull request to our preferred format.--branch-okay
: Do not warn if pulling to a branch besides the repository default (useful for testing).--resolve
: When a patch fails to apply, leave in progress and allow user to resolve, instead of aborting.--warn-on-upload-failure
: Warn instead of raising an error if the bottle upload fails. Useful for repairing bottle uploads that previously failed.--message
: Message to include when autosquashing revision bumps, deletions, and rebuilds.--workflow
: Retrieve artifacts from the specified workflow (default:tests.yml
).--artifact
: Download artifacts with the specified name (default:bottles
).--bintray-org
: Upload to the specified Bintray organisation (default:homebrew
).--tap
: Target tap repository (default:homebrew/core
).--root-url
: Use the specifiedURL
as the root of the bottle’s URL instead of Homebrew’s default.--bintray-mirror
: Use the specified Bintray repository to automatically mirror stable URLs defined in the formulae (default:mirror
).
pr-upload
[options
]
Apply the bottle commit and publish bottles to Bintray or GitHub Releases.
--no-publish
: Apply the bottle commit and upload the bottles, but don’t publish them.--keep-old
: If the formula specifies a rebuild version, attempt to preserve its value in the generated DSL.-n
,--dry-run
: Print what would be done rather than doing it.--no-commit
: Do not generate a new commit before uploading.--warn-on-upload-failure
: Warn instead of raising an error if the bottle upload fails. Useful for repairing bottle uploads that previously failed.--bintray-org
: Upload to the specified Bintray organisation (default:homebrew
).--root-url
: Use the specifiedURL
as the root of the bottle’s URL instead of Homebrew’s default.
prof
[command
]
Run Homebrew with a Ruby profiler, e.g. brew prof readall
.
--stackprof
: Usestackprof
instead ofruby-prof
(the default).
release-notes
[options
] [previous_tag
] [end_ref
]
Print the merged pull requests on Homebrew/brew between two Git refs. If no previous_tag
is provided it defaults to the latest tag. If no end_ref
is provided it defaults to origin/master
.
--markdown
: Print as a Markdown list.
ruby
(-e
text
|file
)
Run a Ruby instance with Homebrew’s libraries loaded, e.g. brew ruby -e "puts :gcc.f.deps"
or brew ruby script.rb
.
-r
: Load a library usingrequire
.-e
: Execute the given text string as a script.
sh
[options
] [file
]
Homebrew build environment that uses years-battle-hardened build logic to help your ./configure && make && make install
and even your gem install
succeed. Especially handy if you run Homebrew in an Xcode-only configuration since it adds tools like make
to your PATH
which build systems would not find otherwise.
--env
: Use the standardPATH
instead of superenv’s whenstd
is passed.-c
,--cmd
: Execute commands in a non-interactive shell.
sponsors
Print a Markdown summary of Homebrew’s GitHub Sponsors, suitable for pasting into a README.
style
[options
] [file
|tap
|formula
]
Check formulae or files for conformance to Homebrew style guidelines.
Lists of file
, tap
and formula
may not be combined. If none are provided, style
will run style checks on the whole Homebrew library, including core code and all formulae.
--fix
: Fix style violations automatically using RuboCop’s auto-correct feature.--display-cop-names
: Include the RuboCop cop name for each violation in the output.--only-cops
: Specify a comma-separatedcops
list to check for violations of only the listed RuboCop cops.--except-cops
: Specify a comma-separatedcops
list to skip checking for violations of the listed RuboCop cops.
tap-new
[options
] user
/
repo
Generate the template files for a new tap.
--no-git
: Don’t initialize a Git repository for the tap.--pull-label
: Label name for pull requests ready to be pulled (default:pr-pull
).--branch
: Initialize Git repository with the specified branch name (default:main
).
test
[options
] formula
Run the test method provided by an installed formula. There is no standard output or return code, but generally it should notify the user if something is wrong with the installed formula.
Example: brew install jruby && brew test jruby
--devel
: Test the development version of a formula.--HEAD
: Test the head version of a formula.--keep-tmp
: Retain the temporary files created for the test.--retry
: Retry if a testing fails.
tests
[options
]
Run Homebrew’s unit and integration tests.
--coverage
: Generate code coverage reports.--generic
: Run only OS-agnostic tests.--no-compat
: Do not load the compatibility layer when running tests.--online
: Include tests that use the GitHub API and tests that use any of the taps for official external commands.--byebug
: Enable debugging using byebug.--only
: Run onlytest_script
_spec.rb
. Appending:
line_number
will start at a specific line.--seed
: Randomise tests with the specifiedvalue
instead of a random seed.
typecheck
Check for typechecking errors using Sorbet.
--fix
: Automatically fix type errors.-q
,--quiet
: Silence all non-critical errors.--update
: Update RBI files.--fail-if-not-changed
: Return a failing status code if all gems are up to date and gem definitions do not need a tapioca update.--dir
: Typecheck all files in a specific directory.--file
: Typecheck a single file.--ignore
: Ignores input files that contain the given string in their paths (relative to the input path passed to Sorbet).
unpack
[options
] formula
Unpack the source files for formula
into subdirectories of the current working directory.
--destdir
: Create subdirectories in the directory named bypath
instead.--patch
: Patches forformula
will be applied to the unpacked source.-g
,--git
: Initialise a Git repository in the unpacked source. This is useful for creating patches for the software.-f
,--force
: Overwrite the destination directory if it already exists.
update-license-data
[options
]
Update SPDX license data in the Homebrew repository.
--fail-if-not-changed
: Return a failing status code if current license data’s version is the same as the upstream. This can be used to notify CI when the SPDX license data is out of date.
update-python-resources
[options
] formula
Update versions for PyPI resource blocks in formula
.
-p
,--print-only
: Print the updated resource blocks instead of changingformula
.-s
,--silent
: Suppress any output.--ignore-non-pypi-packages
: Don’t fail ifformula
is not a PyPI package.--version
: Use the specifiedversion
when finding resources forformula
. If no version is specified, the current version forformula
will be used.
update-test
[options
]
Run a test of brew update
with a new repository clone. If no options are passed, use origin/master
as the start commit.
--to-tag
: SetHOMEBREW_UPDATE_TO_TAG
to test updating between tags.--keep-tmp
: Retain the temporary directory containing the new repository clone.--commit
: Use the specifiedcommit
as the start commit.--before
: Use the commit at the specifieddate
as the start commit.
vendor-gems
Install and commit Homebrew’s vendored gems.
GLOBAL CASK OPTIONS
These options are applicable to subcommands accepting a --cask
flag and all cask
commands.
--appdir
: Target location for Applications (default:/Applications
).--colorpickerdir
: Target location for Color Pickers (default:~/Library/ColorPickers
).--prefpanedir
: Target location for Preference Panes (default:~/Library/PreferencePanes
).--qlplugindir
: Target location for QuickLook Plugins (default:~/Library/QuickLook
).--mdimporterdir
: Target location for Spotlight Plugins (default:~/Library/Spotlight
).--dictionarydir
: Target location for Dictionaries (default:~/Library/Dictionaries
).--fontdir
: Target location for Fonts (default:~/Library/Fonts
).--servicedir
: Target location for Services (default:~/Library/Services
).--input_methoddir
: Target location for Input Methods (default:~/Library/Input Methods
).--internet_plugindir
: Target location for Internet Plugins (default:~/Library/Internet Plug-Ins
).--audio_unit_plugindir
: Target location for Audio Unit Plugins (default:~/Library/Audio/Plug-Ins/Components
).--vst_plugindir
: Target location for VST Plugins (default:~/Library/Audio/Plug-Ins/VST
).--vst3_plugindir
: Target location for VST3 Plugins (default:~/Library/Audio/Plug-Ins/VST3
).--screen_saverdir
: Target location for Screen Savers (default:~/Library/Screen Savers
).--language
: Comma-separated list of language codes to prefer for cask installation. The first matching language is used, otherwise it reverts to the cask’s default language. The default value is the language of your system.
GLOBAL OPTIONS
These options are applicable across multiple subcommands.
-d
,--debug
: Display any debugging information.-q
,--quiet
: Suppress any warnings.-v
,--verbose
: Make some output more verbose.-h
,--help
: Show this message.
OFFICIAL EXTERNAL COMMANDS
bundle
[subcommand
]
Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask, Mac App Store and Whalebrew.
brew bundle
[install
]
Install and upgrade (by default) all dependencies from the Brewfile
.
You can specify the Brewfile
location using --file
or by setting the HOMEBREW_BUNDLE_FILE
environment variable.
You can skip the installation of dependencies by adding space-separated values to one or more of the following environment variables: HOMEBREW_BUNDLE_BREW_SKIP
, HOMEBREW_BUNDLE_CASK_SKIP
, HOMEBREW_BUNDLE_MAS_SKIP
, HOMEBREW_BUNDLE_WHALEBREW_SKIP
, HOMEBREW_BUNDLE_TAP_SKIP
.
brew bundle
will output a Brewfile.lock.json
in the same directory as the Brewfile
if all dependencies are installed successfully. This contains dependency and system status information which can be useful in debugging brew bundle
failures and replicating a “last known good build” state. You can opt-out of this behaviour by setting the HOMEBREW_BUNDLE_NO_LOCK
environment variable or passing the --no-lock
option. You may wish to check this file into the same version control system as your Brewfile
(or ensure your version control system ignores it if you’d prefer to rely on debugging information from a local machine).
brew bundle dump
Write all installed casks/formulae/images/taps into a Brewfile
in the current directory.
brew bundle cleanup
Uninstall all dependencies not listed from the Brewfile
.
This workflow is useful for maintainers or testers who regularly install lots of formulae.
brew bundle check
Check if all dependencies are installed from the Brewfile
.
This provides a successful exit code if everything is up-to-date, making it useful for scripting.
brew bundle list
List all dependencies present in the Brewfile
.
By default, only Homebrew dependencies are listed.
brew bundle exec
command
Run an external command in an isolated build environment based on the Brewfile
dependencies.
This sanitized build environment ignores unrequested dependencies, which makes sure that things you didn’t specify in your Brewfile
won’t get picked up by commands like bundle install
, npm install
, etc. It will also add compiler flags which will help find keg-only dependencies like openssl
, icu4c
, etc.
--file
: Read theBrewfile
from this location. Use--file=-
to pipe to stdin/stdout.--global
: Read theBrewfile
from~/.Brewfile
.-v
,--verbose
:install
prints output from commands as they are run.check
lists all missing dependencies.--no-upgrade
:install
won’t runbrew upgrade
on outdated dependencies. Note they may still be upgraded bybrew install
if needed.-f
,--force
:dump
overwrites an existingBrewfile
.cleanup
actually performs its cleanup operations.--cleanup
:install
performs cleanup operation, same as runningcleanup --force
.--no-lock
:install
won’t output aBrewfile.lock.json
.--all
:list
all dependencies.--formula
:list
Homebrew dependencies.--cask
:list
Homebrew Cask dependencies.--tap
:list
tap dependencies.--mas
:list
Mac App Store dependencies.--whalebrew
:list
Whalebrew dependencies.--describe
:dump
adds a description comment above each line, unless the dependency does not have a description.--no-restart
:dump
does not addrestart_service
to formula lines.--zap
:cleanup
casks using thezap
command instead ofuninstall
.
services
[subcommand
]
Manage background services with macOS’ launchctl
(1) daemon manager.
If sudo
is passed, operate on /Library/LaunchDaemons
(started at boot). Otherwise, operate on ~/Library/LaunchAgents
(started at login).
[sudo
] brew services
[list
]
List all managed services for the current user (or root).
[sudo
] brew services run
(formula
|--all
)
Run the service formula
without registering to launch at login (or boot).
[sudo
] brew services start
(formula
|--all
)
Start the service formula
immediately and register it to launch at login (or boot).
[sudo
] brew services stop
(formula
|--all
)
Stop the service formula
immediately and unregister it from launching at login (or boot).
[sudo
] brew services restart
(formula
|--all
)
Stop (if necessary) and start the service formula
immediately and register it to launch at login (or boot).
[sudo
] brew services cleanup
Remove all unused services.
--all
: Runsubcommand
on all services.
test-bot
[options
] [formula
]
Tests the full lifecycle of a Homebrew change to a tap (Git repository). For example, for a GitHub Actions pull request that changes a formula brew test-bot
will ensure the system is cleaned and set up to test the formula, install the formula, run various tests and checks on it, bottle (package) the binaries and test formulae that depend on it to ensure they aren’t broken by these changes.
Only supports GitHub Actions as a CI provider. This is because Homebrew uses GitHub Actions and it’s freely available for public and private use with macOS and Linux workers.
--dry-run
: Print what would be done rather than doing it.--cleanup
: Clean all state from the Homebrew directory. Use with care!--skip-setup
: Don’t check if the local system is set up correctly.--keep-old
: Runbrew bottle --keep-old
to build new bottles for a single platform.--skip-relocation
: Runbrew bottle --skip-relocation
to build new bottles that don’t require relocation.--local
: Ask Homebrew to write verbose logs under./logs/
and set$HOME
to./home/
--tap
: Use the Git repository of the given tap. Defaults to the core tap for syntax checking.--fail-fast
: Immediately exit on a failing step.-v
,--verbose
: Print test step output in real time. Has the side effect of passing output as raw bytes instead of re-encoding in UTF-8.--test-default-formula
: Use a default testing formula when not building a tap and no other formulae are specified.--bintray-org
: Upload bottles to the given Bintray organisation.--root-url
: Use the specifiedURL
as the root of the bottle’s URL instead of Homebrew’s default.--git-name
: Set the Git author/committer names to the given name.--git-email
: Set the Git author/committer email to the given email.--ci-upload
: Use the Homebrew CI bottle upload options.--publish
: Publish the uploaded bottles.--skip-recursive-dependents
: Only test the direct dependents.--only-cleanup-before
: Only run the pre-cleanup step. Needs--cleanup
.--only-setup
: Only run the local system setup check step.--only-tap-syntax
: Only run the tap syntax check step.--only-formulae
: Only run the formulae steps.--only-cleanup-after
: Only run the post-cleanup step. Needs--cleanup
.
CUSTOM EXTERNAL COMMANDS
Homebrew, like git
(1), supports external commands. These are executable scripts that reside somewhere in the PATH
, named brew-
cmdname
or brew-
cmdname
.rb
, which can be invoked like brew
cmdname
. This allows you to create your own commands without modifying Homebrew’s internals.
Instructions for creating your own commands can be found in the docs: https://docs.brew.sh/External-Commands
SPECIFYING FORMULAE
Many Homebrew commands accept one or more formula
arguments. These arguments can take several different forms:
- The name of a formula: e.g.
git
,node
,wget
. - The fully-qualified name of a tapped formula: Sometimes a formula from a tapped repository may conflict with one in
homebrew/core
. You can still access these formulae by using a special syntax, e.g.homebrew/dupes/vim
orhomebrew/versions/node4
. - An arbitrary file: Homebrew can install formulae from a local path. It can point to either a formula file or a bottle.
SPECIFYING CASKS
Many Homebrew Cask commands accept one or more cask
arguments. These can be specified the same way as the formula
arguments described in SPECIFYING FORMULAE
above.
ENVIRONMENT
Note that environment variables must have a value set to be detected. For example, run export HOMEBREW_NO_INSECURE_REDIRECT=1
rather than just export HOMEBREW_NO_INSECURE_REDIRECT
.
-
HOMEBREW_ARCH
Linux only: Pass this value to a type name representing the compiler’s-march
option.Default:
native
. -
HOMEBREW_ARTIFACT_DOMAIN
Prefix all download URLs, including those for bottles, with this variable. For example,HOMEBREW_ARTIFACT_DOMAIN=http://localhost:8080
will cause a formula with the URLhttps://example.com/foo.tar.gz
to instead download fromhttp://localhost:8080/example.com/foo.tar.gz
. -
HOMEBREW_AUTO_UPDATE_SECS
Automatically check for updates once per this seconds interval.Default:
300
. -
HOMEBREW_BAT
If set, usebat
for thebrew cat
command. -
HOMEBREW_BAT_CONFIG_PATH
Use this as thebat
configuration file.Default:
$HOME/.bat/config
. -
HOMEBREW_BINTRAY_KEY
Use this API key when accessing the Bintray API (where bottles are stored). -
HOMEBREW_BINTRAY_USER
Use this username when accessing the Bintray API (where bottles are stored). -
HOMEBREW_BOTTLE_DOMAIN
Use this URL as the download mirror for bottles. For example,HOMEBREW_BOTTLE_DOMAIN=http://localhost:8080
will cause all bottles to download from the prefixhttp://localhost:8080/
.Default: macOS:
https://homebrew.bintray.com/
, Linux:https://linuxbrew.bintray.com/
. -
HOMEBREW_BREW_GIT_REMOTE
Use this URL as the Homebrew/brewgit
(1) remote.Default:
https://github.com/Homebrew/brew
. -
HOMEBREW_BROWSER
Use this as the browser when opening project homepages.Default:
$BROWSER
or the OS’s default browser. -
HOMEBREW_CACHE
Use this directory as the download cache.Default: macOS:
$HOME/Library/Caches/Homebrew
, Linux:$XDG_CACHE_HOME/Homebrew
or$HOME/.cache/Homebrew
. -
HOMEBREW_CASK_OPTS
Append these options to allcask
commands. All--*dir
options,--language
,--require-sha
,--no-quarantine
and--no-binaries
are supported. For example, you might add something like the following to your~/.profile
,~/.bash_profile
, or~/.zshenv
:export HOMEBREW_CASK_OPTS="--appdir=~/Applications --fontdir=/Library/Fonts"
-
HOMEBREW_CLEANUP_MAX_AGE_DAYS
Cleanup all cached files older than this many days.Default:
120
. -
HOMEBREW_COLOR
If set, force colour output on non-TTY outputs. -
HOMEBREW_CORE_GIT_REMOTE
Use this URL as the Homebrew/homebrew-coregit
(1) remote.Default: macOS:
https://github.com/Homebrew/homebrew-core
, Linux:https://github.com/Homebrew/linuxbrew-core
. -
HOMEBREW_CURLRC
If set, do not pass--disable
when invokingcurl
(1), which disables the use ofcurlrc
. -
HOMEBREW_CURL_RETRIES
Pass the given retry count to--retry
when invokingcurl
(1).Default:
3
. -
HOMEBREW_CURL_VERBOSE
If set, pass--verbose
when invokingcurl
(1). -
HOMEBREW_DEVELOPER
If set, tweak behaviour to be more relevant for Homebrew developers (active or budding) by e.g. turning warnings into errors. -
HOMEBREW_DISABLE_LOAD_FORMULA
If set, refuse to load formulae. This is useful when formulae are not trusted (such as in pull requests). -
HOMEBREW_DISPLAY
Use this X11 display when opening a page in a browser, for example withbrew home
. Primarily useful on Linux.Default:
$DISPLAY
. -
HOMEBREW_DISPLAY_INSTALL_TIMES
If set, print install times for each formula at the end of the run. -
HOMEBREW_EDITOR
Use this editor when editing a single formula, or several formulae in the same directory.Note:
brew edit
will open all of Homebrew as discontinuous files and directories. Visual Studio Code can handle this correctly in project mode, but many editors will do strange things in this case.Default:
$EDITOR
or$VISUAL
. -
HOMEBREW_FAIL_LOG_LINES
Output this many lines of output on formulasystem
failures.Default:
15
. -
HOMEBREW_FORBIDDEN_LICENSES
A space-separated list of licenses. Homebrew will refuse to install a formula if it or any of its dependencies has a license on this list. -
HOMEBREW_FORCE_BREWED_CURL
If set, always use a Homebrew-installedcurl
(1) rather than the system version. Automatically set if the system version ofcurl
is too old. -
HOMEBREW_FORCE_BREWED_GIT
If set, always use a Homebrew-installedgit
(1) rather than the system version. Automatically set if the system version ofgit
is too old. -
HOMEBREW_FORCE_HOMEBREW_ON_LINUX
If set, running Homebrew on Linux will use URLs for macOS. This is useful when merging pull requests for macOS while on Linux. -
HOMEBREW_FORCE_VENDOR_RUBY
If set, always use Homebrew’s vendored, relocatable Ruby version even if the system version of Ruby is new enough. -
HOMEBREW_GITHUB_API_PASSWORD
Use this password for authentication with the GitHub API, for features such asbrew search
. This is deprecated in favour of usingHOMEBREW_GITHUB_API_TOKEN
. -
HOMEBREW_GITHUB_API_TOKEN
Use this personal access token for the GitHub API, for features such asbrew search
. You can create one at https://github.com/settings/tokens. If set, GitHub will allow you a greater number of API requests. For more information, see: https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limitingNote: Homebrew doesn’t require permissions for any of the scopes, but some developer commands may require additional permissions.
-
HOMEBREW_GITHUB_API_USERNAME
Use this username for authentication with the GitHub API, for features such asbrew search
. This is deprecated in favour of usingHOMEBREW_GITHUB_API_TOKEN
. -
HOMEBREW_GIT_EMAIL
Set the Git author and committer email to this value. -
HOMEBREW_GIT_NAME
Set the Git author and committer name to this value. -
HOMEBREW_INSTALL_BADGE
Print this text before the installation summary of each successful build.Default: The “Beer Mug” emoji.
-
HOMEBREW_LIVECHECK_WATCHLIST
Consult this file for the list of formulae to check by default when no formula argument is passed tobrew livecheck
.Default:
$HOME/.brew_livecheck_watchlist
. -
HOMEBREW_LOGS
Use this directory to store log files.Default: macOS:
$HOME/Library/Logs/Homebrew
, Linux:$XDG_CACHE_HOME/Homebrew/Logs
or$HOME/.cache/Homebrew/Logs
. -
HOMEBREW_MAKE_JOBS
Use this value as the number of parallel jobs to run when building withmake
(1).Default: The number of available CPU cores.
-
HOMEBREW_NO_ANALYTICS
If set, do not send analytics. For more information, see: https://docs.brew.sh/Analytics -
HOMEBREW_NO_AUTO_UPDATE
If set, do not automatically update before runningbrew install
,brew upgrade
orbrew tap
. -
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK
If set, fail on the failure of installation from a bottle rather than falling back to building from source. -
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK
If set, do not check for broken dependents after installing, upgrading or reinstalling formulae. -
HOMEBREW_NO_COLOR
If set, do not print text with colour added.Default:
$NO_COLOR
. -
HOMEBREW_NO_COMPAT
If set, disable all use of legacy compatibility code. -
HOMEBREW_NO_EMOJI
If set, do not printHOMEBREW_INSTALL_BADGE
on a successful build.Note: Will only try to print emoji on OS X Lion or newer.
-
HOMEBREW_NO_GITHUB_API
If set, do not use the GitHub API, e.g. for searches or fetching relevant issues after a failed install. -
HOMEBREW_NO_INSECURE_REDIRECT
If set, forbid redirects from secure HTTPS to insecure HTTP.Note: While ensuring your downloads are fully secure, this is likely to cause from-source SourceForge, some GNU & GNOME-hosted formulae to fail to download.
-
HOMEBREW_NO_INSTALL_CLEANUP
If set,brew install
,brew upgrade
andbrew reinstall
will never automatically cleanup installed/upgraded/reinstalled formulae or all formulae every 30 days. -
HOMEBREW_PRY
If set, use Pry for thebrew irb
command. -
HOMEBREW_SKIP_OR_LATER_BOTTLES
If set along withHOMEBREW_DEVELOPER
, do not use bottles from older versions of macOS. This is useful in development on new macOS versions. -
HOMEBREW_SORBET_RUNTIME
If set, enable runtime typechecking using Sorbet. -
HOMEBREW_SVN
Use this as thesvn
(1) binary.Default: A Homebrew-built Subversion (if installed), or the system-provided binary.
-
HOMEBREW_TEMP
Use this path as the temporary directory for building packages. Changing this may be needed if your system temporary directory and Homebrew prefix are on different volumes, as macOS has trouble moving symlinks across volumes when the target does not yet exist. This issue typically occurs when using FileVault or custom SSD configurations.Default: macOS:
/private/tmp
, Linux:/tmp
. -
HOMEBREW_UPDATE_REPORT_ONLY_INSTALLED
If set,brew update
only lists updates to installed software. -
HOMEBREW_UPDATE_TO_TAG
If set, always use the latest stable tag (even if developer commands have been run). -
HOMEBREW_VERBOSE
If set, always assume--verbose
when running commands. -
HOMEBREW_DEBUG
If set, always assume--debug
when running commands. -
HOMEBREW_VERBOSE_USING_DOTS
If set, verbose output will print a.
no more than once a minute. This can be useful to avoid long-running Homebrew commands being killed due to no output. -
all_proxy
Use this SOCKS5 proxy forcurl
(1),git
(1) andsvn
(1) when downloading through Homebrew. -
ftp_proxy
Use this FTP proxy forcurl
(1),git
(1) andsvn
(1) when downloading through Homebrew. -
http_proxy
Use this HTTP proxy forcurl
(1),git
(1) andsvn
(1) when downloading through Homebrew. -
https_proxy
Use this HTTPS proxy forcurl
(1),git
(1) andsvn
(1) when downloading through Homebrew. -
no_proxy
A comma-separated list of hostnames and domain names excluded from proxying bycurl
(1),git
(1) andsvn
(1) when downloading through Homebrew. -
SUDO_ASKPASS
If set, pass the-A
option when callingsudo
(8).
USING HOMEBREW BEHIND A PROXY
Set the http_proxy
, https_proxy
, all_proxy
, ftp_proxy
and/or no_proxy
environment variables documented above.
For example, to use an unauthenticated HTTP or SOCKS5 proxy:
export http_proxy=http://$HOST:$PORT
export all_proxy=socks5://$HOST:$PORT
And for an authenticated HTTP proxy:
export http_proxy=http://$USER:$PASSWORD@$HOST:$PORT
SEE ALSO
Homebrew Documentation: https://docs.brew.sh
Homebrew API: https://rubydoc.brew.sh
git
(1), git-log
(1)
AUTHORS
Homebrew’s Project Leader is Mike McQuaid.
Homebrew’s Project Leadership Committee is Misty De Meo, Shaun Jackman, Jonathan Chang, Sean Molenaar and Markus Reiter.
Homebrew’s Technical Steering Committee is Michka Popoff, FX Coudert, Markus Reiter, Misty De Meo and Mike McQuaid.
Homebrew/brew’s Linux maintainers are Michka Popoff, Shaun Jackman, Dawid Dziurla, Issy Long and Maxim Belkin.
Homebrew’s other current maintainers are Claudia Pellegrino, Zach Auten, Rui Chen, Vitor Galvao, Caleb Xu, Gautham Goli, Steven Peters, Bo Anderson, William Woodruff, Igor Kapkov, Sam Ford, Alexander Bayandin, Izaak Beekman, Eric Knibbe, Viktor Szakats, Thierry Moisan, Steven Peters, Tom Schoonjans, Issy Long, CoreCode, Randall, Rylan Polster, SeekingMeaning, William Ma and Dustin Rodrigues.
Former maintainers with significant contributions include Jan Viljanen, JCount, commitay, Dominyk Tiller, Tim Smith, Baptiste Fontaine, Xu Cheng, Martin Afanasjew, Brett Koonce, Charlie Sharpsteen, Jack Nagel, Adam Vandenberg, Andrew Janke, Alex Dunn, neutric, Tomasz Pajor, Uladzislau Shablinski, Alyssa Ross, ilovezfs, Chongyu Zhu and Homebrew’s creator: Max Howell.
BUGS
See our issues on GitHub:
- Homebrew/brew:
https://github.com/Homebrew/brew/issues - Homebrew/homebrew-core:
https://github.com/Homebrew/homebrew-core/issues - Homebrew/homebrew-cask:
https://github.com/Homebrew/homebrew-cask/issues
Documentation
https://docs.brew.sh/
Users
brew
man-page (command documentation)- Homebrew Blog (news on major updates)
- Troubleshooting
- Installation
- Frequently Asked Questions
- Common Issues
brew
Shell Completion- Tips and Tricks
- Bottles (binary packages)
- Taps (third-party repositories)
- Interesting Taps and Forks
- C++ Standard Libraries
- MD5 and SHA-1 Deprecation
- Custom GCC and Cross Compilers
- External Commands
- Ruby Gems, Python Eggs and Perl Modules
- Python
- How To Build Software Outside Homebrew With Homebrew
keg_only
dependencies - Creating a Homebrew Issue
- Updating Software in Homebrew
- Kickstarter Supporters
Contributors
- How To Open A Pull Request (and get it merged)
- Formula Cookbook
- Acceptable Formulae
- License Guidelines
- Formulae Versions
- Node for Formula Authors
- Python for Formula Authors
- Migrating A Formula To A Tap
- Rename A Formula
- Building Against Non-Homebrew Dependencies
- How To Create (And Maintain) A Tap
- Brew Test Bot
- Diagram Guidelines
- Prose Style Guidelines
- Type Checking with Sorbet
Install Homebrew on Mac OS
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-homebrew-on-macos
Introduction
The command line interface is a non-graphical way to interact with your computer. Instead of clicking buttons with your mouse, you’ll type commands as text and receive text-based feedback. The command line, also known as a shell, lets you automate many tasks you do on your computer daily, and is an essential tool for software developers.
While the command line interface on macOS has a lot of the functionality you’d find in Linux and other Unix systems, it does not ship with a good package manager. A package manager is a collection of software tools that work to automate software installations, configurations, and upgrades. Package managers keep the software they install in a central location and can maintain all software packages on the system in formats that are commonly used.
Homebrew is a package manager for macOS which lets you install free and open-source software using your terminal. You’ll use Homebrew to install developer tools like Python, Ruby, Node.js, and more.
In this tutorial you’ll install and use Homebrew on your Mac.
Prerequisites
You will need a macOS computer running High Sierra or higher with administrative access and an internet connection.
Step 1 — Using the macOS Terminal
To access the command line interface on your Mac, you’ll use the Terminal application provided by macOS. Like any other application, you can find it by going into Finder, navigating to the Applications
folder, and then into the Utilities
folder. From here, double-click the Terminal application to open it up. Alternatively, you can use Spotlight by holding down the COMMAND
key and pressing SPACE
to find Terminal by typing it out in the box that appears.
To get more comfortable using the command line, take a look at An Introduction to the Linux Terminal. The command line interface on macOS is very similar, and the concepts in that tutorial are directly applicable.
Now that you have the Terminal running, let’s install some additional tools that Homebrew needs.
Step 2 — Installing Xcode’s Command Line Tools
Xcode is an integrated development environment (IDE) that is comprised of software development tools for macOS. You won’t need Xcode to use Homebrew, but some of the software and components you’ll want to install will rely on Xcode’s Command Line Tools package.
Execute the following command in the Terminal to download and install these components:
xcode-select --install
You’ll be prompted to start the installation, and then prompted again to accept a software license. Then the tools will download and install automatically.
You can now install Homebrew.
Step 3 — Installing and Setting Up Homebrew
To install Homebrew, you’ll download an installation script and then execute the script.
First, download the script to your local machine by typing the following command in your Terminal window:
curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/master/install.sh
The command uses curl
to download the Homebrew installation script from Homebrew’s Git repository on GitHub.
Let’s walk through the flags that are associated with the curl
command:
- The –
f
or--fail
flag tells the Terminal window to give no HTML document output on server errors. - The
-s
or--silent
flag mutescurl
so that it does not show the progress meter, and combined with the-S
or--show-error
flag it will ensure thatcurl
shows an error message if it fails. - The
-L
or--location
flag will tellcurl
to handle redirects. If the server reports that the requested page has moved to a different location, it’ll automatically execute the request again using the new location. - The
-o
switch specifies a local filename for the file.
Before running a script you’ve download from the Internet, you should review its contents so you know what the script will do. Use the less
command to look at the installation script:
less install.sh
Once you’re comfortable with the contents of the script, execute the script with the bash
command:
/bin/bash install.sh
The installation script will explain what it will do and will prompt you to confirm that you want to do it. This lets you know exactly what Homebrew is going to do to your system before you let it proceed. It also ensures you have the prerequisites in place before it continues.
You’ll be prompted to enter your password during the process. However, when you type your password, your keystrokes will not display in the Terminal window. This is a security measure and is something you’ll see often when prompted for passwords on the command line. Even though you don’t see them, your keystrokes are being recorded by the system, so press the RETURN
key once you’ve entered your password.
Press the letter y
for “yes” whenever you are prompted to confirm the installation.
Once the installation process is complete, you will want to put the directory Homebrew uses to store its executables at the front of the PATH
environment variable. This ensures that Homebrew installations will be called over the tools that macOS includes.
The file you’ll modify depends on which shell you’re using. If you’re using Bash, you’ll use the file ~/.bash_profile
:
nano ~/.bash_profile
However, if you’re using ZSH, you’ll open the file ~/.zshrc
.
nano ~/.zshrc
Once the file opens up in the Terminal window, add the following lines to the end of the file:
~/.bash_profile
# Add Homebrew's executable directory to the front of the PATH
export PATH=/usr/local/bin:$PATH
The first line is a comment that will help you remember what this does if you open this file in the future.
To save your changes, hold down the CTRL
key and the letter O
, and when prompted, press the RETURN
key. Then exit the editor by holding the CTRL
key and pressing X
. This will return you to your Terminal prompt.
To activate these changes, close and reopen your Terminal app. Alternatively, use the source
command to load the file you modified.
If you modified .bash_profile
, execute this command:
source ~/.bash_profile
If you modified .zshrc
, execute this command:
source ~/.zshrc
Once you have done this, the changes you have made to the PATH
environment variable will take effect. They’ll be set correctly when you log in again in the future, as the configuration file for your shell is executed automatically when you open the Terminal app.
Now let’s verify that Homebrew is set up correctly. Execute this command:
brew doctor
If no updates are required at this time, you’ll see this in your Terminal:
OutputYour system is ready to brew.
Otherwise, you may get a warning to run another command such as brew update
to ensure that your installation of Homebrew is up to date. Follow any on-screen instructions to fix your environment before moving on.
Step 4 — Installing, Upgrading, and Removing Packages
Now that Homebrew is installed, use it to download a package. The tree
command lets you see a graphical directory tree and is available via Homebrew.
Install tree
with the brew install
command:
brew install tree
Homebrew will update its list of packages and then download and install the tree
command:
Output
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/tree-1.8.0.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring tree-1.8.0.catalina.bottle.tar.gz
🍺 /usr/local/Cellar/tree/1.8.0: 8 files, 117.2KB
Homebrew installs files to /usr/local
by default, so they won’t interfere with future macOS updates. Verify that tree
is installed by displaying the command’s location with the which
command:
which tree
The output shows that tree
is located in /usr/local/bin
:
Output/usr/local/bin/tree
Run the tree
command to see the version:
tree --version
The version prints to the screen, indicating it’s installed:
Outputtree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
Occasionally, you’ll want to upgrade an existing package. Use the brew upgrade
command, followed by the package name:
brew upgrade tree
You can run brew upgrade
with no additional arguments to upgrade all programs and packages Homebrew manages.
When you install a new version, Homebrew keeps the older version around. After a while, you might want to reclaim disk space by removing these older copies. Run brew cleanup
to remove all old versions of your Homebrew-managed software.
To remove a package you’re no longer using, use brew uninstall
. To uninstall the tree
command, execute this command:
brew uninstall tree
The output shows that the package was removed:
OutputUninstalling /usr/local/Cellar/tree/1.8.0... (8 files, 117.2KB)
You can use Homebrew to install desktop applications too.
Step 5 — Installing Desktop Applications
You’re not restricted to using Homebrew for command-line tools. Homebrew Cask lets you install desktop applications. This feature is included with Homebrew, so there’s nothing additional to install.
To use Homebrew to install Visual Studio Code, execute the following command:
brew cask install visual-studio-code
The application will install:
OutputUpdating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
abstract cacher chirp sipgate-softphone
==> Downloading https://update.code.visualstudio.com/1.48.2/darwin/stable
==> Downloading from https://az764295.vo.msecnd.net/stable/a0479759d6e9ea56afa657e454193f72aef85bd0/VSC
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'visual-studio-code'.
==> Installing Cask visual-studio-code
==> Moving App 'Visual Studio Code.app' to '/Applications/Visual Studio Code.app'.
==> Linking Binary 'code' to '/usr/local/bin/code'.
🍺 visual-studio-code was successfully installed!
You’ll find the application in your Applications
folder, just as if you’d installed it manually.
To remove it, use brew cask uninstall
:
brew cask uninstall visual-studio-code
Homebrew will remove the installed software:
Output==> Uninstalling Cask visual-studio-code
==> Backing App 'Visual Studio Code.app' up to '/usr/local/Caskroom/visual-studio-code/1.48.2/Visual St
==> Removing App '/Applications/Visual Studio Code.app'.
==> Unlinking Binary '/usr/local/bin/code'.
==> Purging files for version 1.48.2 of Cask visual-studio-code
It performs a backup first in case the removal fails, but once the program is fully uninstalled, the backup is removed as well.
Step 6 — Uninstalling Homebrew
If you no longer need Homebrew, you can use its uninstall script.
Download the uninstall script with curl
:
curl -fsSL -o uninstall.sh https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh
As always, review the contents of the script with the less
command to verify the script’s contents:
less uninstall.sh
Once you’ve verified the script, execute the script with the --help
flag to see the various options you can use:
bash uninstall.sh --help
The options display on the screen:
OutputHomebrew Uninstaller
Usage: uninstall.sh [options]
-p, --path=PATH Sets Homebrew prefix. Defaults to /usr/local.
--skip-cache-and-logs
Skips removal of HOMEBREW_CACHE and HOMEBREW_LOGS.
-f, --force Uninstall without prompting.
-q, --quiet Suppress all output.
-d, --dry-run Simulate uninstall but don't remove anything.
-h, --help Display this message.
Use the -d
flag to see what the script will do:
bash uninstall.sh -d
The script will list everything it will delete:
OutputWarning: This script would remove:
/Users/brianhogan/Library/Caches/Homebrew/
/Users/brianhogan/Library/Logs/Homebrew/
/usr/local/Caskroom/
/usr/local/Cellar/
/usr/local/bin/brew -> /usr/local/bin/brew
==> Removing Homebrew installation...
Would delete:
....
When you’re ready to remove everything, execute the script without any flags:
bash uninstall.sh
This removes Homebrew and any programs you’ve installed with it.
Conclusion
In this tutorial you installed and used Homebrew on your Mac. You can now use Homebrew to install command line tools, programming languages, and other utilities you’ll need for software development.
Homebrew has many packages you can install. Visit the official list to search for your favorite programs.