The command line interface is a non-graphical tool that allows users to interact with their computer by typing text-based commands. It is an essential tool for software developers, letting them automate many daily tasks. While the macOS command line offers much of the functionality found in other Unix systems, it does not ship with a native package manager. Homebrew is a popular free and open-source package manager for macOS that fills this gap, allowing you to install developer tools like Python, Ruby, and Node.js directly from your terminal.
In this tutorial, you will install and use Homebrew on your Mac. The guide will walk you through installing prerequisites like Xcode’s Command Line Tools and then running the Homebrew installation script. You will learn how to install, upgrade, and remove packages from the command line. Additionally, this article covers how to use Homebrew Cask to install desktop applications and provides the steps for uninstalling Homebrew if you no longer need it.
Key Takeaways:
xcode-select --install
in the terminal. The installation process involves downloading and running a script from Homebrew’s Git repository.PATH
environment variable to include Homebrew’s directory, which ensures that packages installed by Homebrew are found by the system. You can verify that Homebrew is set up correctly by running the brew doctor
command.brew install tree
to add a new package and brew uninstall tree
to remove it. To update all installed packages to their latest versions, you can run brew upgrade
.brew install --cask <application_name>
places the program in your main Applications
folder.brew services
command allows you to manage background processes, such as databases or web servers, that need to run continuously. It provides a simple way to start, stop, and list services managed by Homebrew.Brewfile
can be used to create reproducible development environments by listing all required packages, casks, and taps in a single text file. You can generate this file from your current setup with brew bundle dump
and install everything on a new machine with brew bundle install
.brew tap
to add third-party repositories, also known as taps. This gives you access to thousands of additional packages, such as the extensive font collection in the homebrew/cask-fonts
tap.brew doctor
is the primary diagnostic tool that checks for common issues and suggests fixes. Many problems, such as “command not found” errors, can be resolved by running brew update
or ensuring your PATH
variable is correctly configured in your shell’s profile (~/.zshrc
or ~/.bash_profile
).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. You’ll install system tools and desktop applications from the command line interface.
Deploy your applications from GitHub using DigitalOcean App Platform. Let DigitalOcean focus on scaling your app.
You will need a macOS computer running Catalina or higher with administrative access and an internet connection. While older versions of macOS may work, they are not officially supported.
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] (https://www.digitalocean.com/community/tutorials/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.
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.
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/HEAD/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:
f
or --fail
flag tells the Terminal window to give no HTML document output on server errors.-s
or --silent
flag mutes curl
so that it does not show the progress meter, and combined with the -S
or --show-error
flag it will ensure that curl
shows an error message if it fails.-L
or --location
flag will tell curl
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.-o
switch specifies a local filename for the file. Rather than displaying the contents to the screen, the -o
switch saves the contents into the file you specify.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 review the installation script so you understand what it will do:
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. ZSH is the default shell on macOS Mojave and higher. The Bash shell is a popular shell that older versions of macOS used as the default, and if you’ve upgraded your OS, you may still be using Bash.
Execute the following command to determine your shell:
echo $0
You’ll see either bash
or zsh
.
If you’re using ZSH, you’ll open the file ~/.zshrc
in your editor:
nano ~/.zshrc
If you’re using the Bash shell, you’ll use the file ~/.bash_profile
:
nano ~/.bash_profile
Once the file opens up in the Terminal window, add the following lines to the end of the file:
# 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 .zshrc
, execute this command:
source ~/.zshrc
If you modified .bash_profile
, execute this command:
source ~/.bash_profile
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.
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:
OutputUpdating 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.
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.
While the standard Homebrew packages, known as formulae, typically handle command-line software, casks extend this capability to graphical user interface (GUI) applications. A cask is a script that automates the process of downloading a macOS application, such as its .dmg
or .zip
file, and moving it to your Applications
folder. This gives you a way to manage both command-line tools and desktop apps using the same simple brew
commands.
Before installing an application, you may want to check if it’s available as a cask. You can do this with the brew search
command. For example, to find out if the Firefox browser is available, you would run:
brew search firefox
Homebrew will return a list of matching formulae and casks. Casks are usually clearly marked.
Output==> Casks
firefox firefox-beta firefox-developer-edition firefox-esr firefox-nightly
Let’s test it out by using Homebrew to install Visual Studio Code. Execute the following command in your terminal:
brew install visual-studio-code
The application will install:
Output==> Downloading https://update.code.visualstudio.com/1.58.2/darwin/stable
==> Downloading from https://az764295.vo.msecnd.net/stable/c3f126316369cd610563c75b1b1725e0679adfb3/VSCode-darwin.zip
######################################################################## 100.0%
==> 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.
While the command above works, the current recommended syntax is to include the --cask
flag for clarity. This helps distinguish between installing a formula and a cask, especially when they share similar names. The updated command would be:
brew install --cask visual-studio-code
Homebrew is smart enough to figure out your intent in most cases, but using the --cask
flag is a good practice to adopt.
You can manage your cask installations with a few simple commands. To see a list of all the cask applications you’ve installed, run:
brew list --cask
To get more detailed information about a specific cask, such as its version and installation date, use the brew info --cask
command:
brew info --cask visual-studio-code
To remove it, use brew uninstall
:
brew 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.58.2/Visual Studio Code.app'
==> Removing App '/Applications/Visual Studio Code.app'
==> Unlinking Binary '/usr/local/bin/code'
==> Purging files for version 1.58.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. For a more thorough removal that also deletes configuration files associated with the application, you can add the --zap
flag:
brew uninstall --cask --zap visual-studio-code
Be careful with the --zap
flag, as it will permanently delete all data associated with the application.
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.
brew services
Many developer tools, such as databases or web servers, need to run continuously in the background. Homebrew provides a simple command, brew services
, to manage these background processes directly from the command line. This utility integrates with launchd
, the standard macOS service manager, to start, stop, and list your services.
Let’s see how this works with a practical example: installing and managing the PostgreSQL database.
First, install PostgreSQL using the standard brew install
command:
brew install postgresql
Once the installation is complete, you can use brew services
to start it.
brew services start postgresql
This command starts the PostgreSQL server immediately and configures it to launch automatically every time you log in.
Output
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
To see a list of all services that Homebrew is currently managing, use the list
subcommand:
brew services list
The output shows the service name, its status, and the user it’s running as.
Output
Name Status User File
postgresql started your_user ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
If you need to stop the service, you can use the stop
subcommand:
brew services stop postgresql
This stops the service and prevents it from launching at login. The following table summarizes the most common brew services
commands for quick reference.
Command | Description |
---|---|
brew services start name |
Starts the specified service and registers it to run at login. |
brew services stop name |
Stops the specified service and unregisters it from running at login. |
brew services restart name |
Stops and then starts the service. |
brew services run name |
Starts the service without registering it to run at login. |
brew services list |
Lists all services managed by Homebrew and their status. |
Using brew services
provides a consistent way to manage your development-related daemons without manually configuring launchd
.
When setting up a new computer or onboarding a team member, ensuring a consistent development environment is important. A Brewfile is a plain text file that defines all your required Homebrew packages, including command-line formulae, desktop applications (casks), and even Mac App Store apps. This allows you to install all your dependencies with a single command.
You can create a Brewfile that captures every package currently installed on your system. This is a good way to back up your existing setup.
Navigate to a directory where you want to save the file, such as your home directory or a dotfiles repository, and run the bundle dump
command:
brew bundle dump
This creates a file named Brewfile
in your current directory. Its contents will look something like this:
# Taps
tap "homebrew/cask-fonts"
tap "homebrew/core"
# Formulae
brew "git"
brew "node"
brew "tree"
# Casks
cask "visual-studio-code"
cask "docker"
When you move to a new machine, you can place this Brewfile
in your home directory and run the bundle install
command to set up your environment:
brew bundle install
Homebrew will read the Brewfile
, install any missing packages, and skip any that are already installed. This makes the process repeatable and safe to run multiple times. This is also useful for project-specific dependencies. You can include a Brewfile
in a project’s repository to ensure every developer has the required tools.
brew tap
The default Homebrew installation includes a core set of formulae, but there are thousands of other packages available through third-party repositories. In Homebrew, these repositories are called taps. The brew tap
command allows you to add (or “tap”) these external repositories, making their packages available for installation.
A popular example is the homebrew/cask-fonts
tap, which contains a large collection of open-source fonts.
To add this tap, run the following command:
brew tap homebrew/cask-fonts
Once the tap is added, you can search for and install packages from it just like you would with core packages. For example, to install the Fira Code font, you would use:
brew install --cask fira-code
Homebrew automatically knows to look for fira-code
in your tapped repositories. Taps greatly expand the universe of software that Homebrew can manage, giving you access to specialized tools and applications maintained by the community.
While brew doctor
is the primary command for diagnosing issues with your Homebrew installation, a few other commands can provide deeper information.
brew config
: This command displays a summary of your system’s configuration as Homebrew sees it. This information is very useful when you are filing a bug report, as it provides maintainers with the context they need.
brew deps --tree <formula>
: This command shows you the dependency tree for a specific package. It helps you understand why certain packages were installed and how they relate to each other. For example, running brew deps --tree wget
shows all the libraries wget
depends on:
brew deps --tree wget
Output
wget
├── gettext
├── libunistring
├── libidn2
│ ├── libunistring
│ └── gettext
└── openssl@3
└── ca-certificates
These commands give you greater visibility into your Homebrew environment, making it easier to manage dependencies and resolve problems.
Homebrew is generally reliable, but you might encounter issues from time to time. Most problems are easy to fix. This section covers common mistakes and the steps to resolve them.
A good first step for any issue is to run Homebrew’s built-in diagnostic tool:
brew doctor
This command checks your system for potential problems and often provides the exact commands needed to fix them. If brew doctor
reports Your system is ready to brew
, but you still have problems, check out the following common issues.
Many installation errors for formulae or casks happen because your local copy of Homebrew is out of date. You might see errors like Error: Cask 'some-cask' is unreadable
or fetching failures. Before assuming a package is broken, get the latest version of Homebrew and update the core formulae:
brew update
It’s also good practice to upgrade your installed packages to their latest versions:
brew upgrade
Running these two commands regularly can prevent many common problems.
Sometimes, after installing a tool, your shell reports command not found
when you try to use it. This is almost always a PATH
configuration issue. The PATH
is an environment variable that tells your shell where to look for executable programs.
First, find where Homebrew is installed.
brew --prefix
/opt/homebrew
./usr/local
.The executables you install will be in the bin
subdirectory of this path (e.g., /opt/homebrew/bin
).
PATH
Display your current PATH
to see if the correct Homebrew directory is included.
echo $PATH
Look for /opt/homebrew/bin
(Apple Silicon) or /usr/local/bin
(Intel) in the output. It should be near the beginning of the PATH
string.
PATH
If the path is missing, you need to add it to your shell’s configuration file. For Zsh, which is the default shell on modern macOS, this file is ~/.zshrc
.
Open the file in a text editor like nano
:
nano ~/.zshrc
Add the correct line for your system at the end of the file.
For Apple Silicon:
# ~/.zshrc
export PATH="/opt/homebrew/bin:$PATH"
For Intel:
# ~/.zshrc
export PATH="/usr/local/bin:$PATH"
Save the file (CTRL+O
, Enter
) and exit nano
(CTRL+X
). Then, apply the changes to your current terminal session:
source ~/.zshrc
The command you installed should now work correctly.
Sometimes, brew install
fails midway through the process. Here are two common causes.
If a formula needs to be compiled from source, it requires Apple’s Command Line Tools. If they are missing, you will see an error related to xcrun
or a missing compiler.
To fix this, install the tools with this command:
xcode-select --install
A dialog box will appear. Follow the prompts to complete the installation, and then try your brew install
command again.
On older Intel-based Macs, you might see permission errors related to the /usr/local/
directory. This happens when the current user does not have write permissions for Homebrew’s directories.
An example error might look like this: Error: /usr/local/Cellar is not writable.
You can fix this by changing the ownership of the Homebrew directory to your current user.
sudo chown -R $(whoami) /usr/local/*
This issue is uncommon on Apple Silicon Macs because Homebrew installs into /opt/homebrew/
, a directory that the installer configures with the correct permissions from the start.
When a Homebrew installation fails or brew doctor
reports a warning, the resulting error messages can be difficult to understand. Instead of searching through forums for a solution, you can use an AI language model to diagnose the problem and get a direct solution.
For instance, imagine you run brew install libvips
and receive the following error:
Output==> Installing dependencies for libvips: glib
==> Installing libvips dependency: glib
==> ./configure --disable-silent-rules --prefix=/opt/homebrew/Cellar/glib/2.80.0 --with-pcre=system
==> make
Last 15 lines from /Users/sammy/Library/Logs/Homebrew/glib/02.make:
GEN glib-gettextize
glib-gettextize.c:23:10: fatal error: 'libintl.h' file not found
#include <libintl.h>
^~~~~~~~~~~
1 error generated.
make[3]: *** [glib-gettextize] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Do not report this issue to Homebrew/brew or Homebrew/core!
This error can be frustrating. However, you can copy this entire output and paste it into an AI assistant with a simple prompt.
Example Prompt:
> I got the error below while trying to install a package with Homebrew. Can you explain what went wrong and give me the steps to fix it?
> [Paste the full error log here]
An AI assistant can analyze the log, identify the root cause—in this case, the missing libintl.h
file points to a dependency on gettext
—and provide a clear, step-by-step solution.
Example AI Response:
The error fatal error: 'libintl.h' file not found
indicates that a required dependency, gettext
, is not properly linked in your system. Homebrew usually handles this, but sometimes it needs to be done manually.
Here’s how to fix it:
Install or relink gettext
: First, ensure gettext
is installed and up to date.
brew install gettext
Force the link: Next, force-link the formula to make its libraries available to other packages.
brew link --force gettext
Retry the installation: Once the link is created, try installing your original package again.
brew install libvips
This approach transforms a potential roadblock into a quick fix and a chance to understand how package dependencies work.
A Brewfile is a text file that lists all the Homebrew packages you want to install. It’s an efficient way to set up a new computer or ensure all members of a development team have the same tools. Instead of creating this file manually, you can describe your needs in plain English to an AI assistant and have it generate the file for you.
Example Prompt:
I'm a Python web developer setting up a new MacBook. I use VS Code, iTerm2, and PostgreSQL. I also need tools like git, nvm for Node.js management, and Docker. Generate a complete Brewfile for me.
The AI can process this request and produce a perfectly formatted Brewfile
.
Example AI Response:
Certainly. Here is a Brewfile
based on your requirements. Save it as Brewfile
in your home directory.
# Brewfile for a Python Web Developer
# Taps
tap "homebrew/bundle"
# Command-line tools (Formulae)
brew "git"
brew "nvm"
brew "python"
brew "postgresql"
# Desktop Apps (Casks)
cask "visual-studio-code"
cask "iterm2"
cask "docker"
After saving the file, navigate to its directory in your terminal and run brew bundle install
. Homebrew will automatically install every package listed.
This method is fast, accurate, and ensures you don’t forget any essential tools during setup.
Sometimes you have a problem to solve but don’t know which command-line tool is right for the job. An AI assistant can act as a discovery engine, recommending the best Homebrew packages for your specific task.
Example Prompt:
I need a command-line tool for my Mac that can convert HEIC images to JPEG in bulk. What can I install with Homebrew?
The AI can suggest a suitable tool and even provide the commands to install and use it.
Example AI Response:
The best tool for this is ImageMagick, a powerful command-line image processing suite.
Install ImageMagick: You can install it with Homebrew by running:
brew install imagemagick
Convert your images: Navigate to the folder containing your .HEIC
files and run the following command to convert all of them to JPEG format:
magick mogrify -format jpg *.HEIC
This command will create a JPEG version of each HEIC file in the same directory.
This interaction saves you from having to search for tools and read through documentation, allowing you to solve your problem in minutes.
You can use AI to write shell scripts that automate your Homebrew workflows. This is useful for creating custom maintenance routines or checks that go beyond standard brew
commands. For example, you might want to be notified only when a critical package has a security update pending.
Example Prompt:
> Write a shell script that checks for outdated Homebrew packages. If the `openssl` package is in the list of outdated packages, it should print a warning message. Otherwise, it should remain silent.
An AI can generate a functional script based on this request.
Example AI Response:
Here is a shell script that checks for an openssl
update. You can save it as check_updates.sh
and run it periodically.
#!/bin/bash
# Fetches the latest package information from Homebrew
echo "Checking for updates..."
brew update > /dev/null 2>&1
# Get a list of all outdated Homebrew packages
OUTDATED_PACKAGES=$(brew outdated)
# Check if 'openssl' is in the list of outdated packages
if echo "$OUTDATED_PACKAGES" | grep -q "openssl"; then
echo "⚠️ Warning: A critical update for openssl is available. Run 'brew upgrade openssl' as soon as possible."
else
echo "All critical packages are up to date."
fi
To make the script executable, run chmod +x check_updates.sh
. You can then run it anytime with ./check_updates.sh
.
By generating custom scripts, you can create automated, personalized workflows that fit your exact needs.
Homebrew is a free and open-source package manager for macOS that allows you to install software through the command line. A package manager is a set of tools that automates the installation, configuration, and upgrading of software. You can use Homebrew to install developer tools such as Python, Ruby, and Node.js.
Installing Homebrew involves a few steps from the macOS Terminal.
xcode-select --install
.curl
command to download the official installation script from Homebrew’s repository: curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
.bash
: /bin/bash install.sh
. You will be prompted to enter your password to proceed.PATH
. Add export PATH=/usr/local/bin:$PATH
to your ~/.zshrc
(for Zsh) or ~/.bash_profile
(for Bash) file.brew doctor
to ensure Homebrew is set up correctly. If the output is Your system is ready to brew
, the installation was successful.You can use the brew install
command to install both command-line tools and desktop applications.
tree
command, you would run brew install tree
.brew install visual-studio-code
. The application will be placed in your computer’s Applications
folder.Homebrew is used to install command-line software, while Homebrew Cask is a feature within Homebrew used to install graphical desktop applications. Cask is included with the main Homebrew installation, so you don’t need to install anything extra to use it.
You can find available packages using the brew search
command followed by the name of the software you’re looking for. Homebrew will search its list of both command-line tools (formulae) and desktop applications (casks). For example, to search for the wget
utility, you would run:
brew search wget
This command will return a list of packages that match your search term.
To remove a package, you use the brew uninstall
command followed by the package name. This works for both command-line tools and desktop applications.
brew uninstall tree
brew uninstall visual-studio-code
Homebrew will remove the program and its related files from your system.
To uninstall Homebrew, you must first download the official uninstall script.
curl
to fetch the script: curl -fsSL -o uninstall.sh https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh
.bash uninstall.sh
.This command will remove Homebrew and all the software you installed with it from your system.
You have now successfully installed and configured Homebrew, allowing you to manage both command-line tools and graphical desktop applications directly from your terminal. With this powerful package manager, you can streamline your development workflow by managing background services with brew services
and creating reproducible environments using a Brewfile
. You can also expand the available software by adding third-party repositories with brew tap
. You are now equipped to diagnose and resolve common issues with brew doctor
, giving you full control over your development environment. Go ahead and explore the thousands of packages now available to you with a single command.
Homebrew has many packages you can install. Visit Homebrew Formulae to search for your favorite programs.
To continue setting up your development tools, you can follow our guides for installing a specific programming language like Ruby on macOS or for setting up a package manager on a Linux server:
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Managed the Write for DOnations program, wrote and edited community articles, and makes things on the Internet. Expertise in DevOps areas including Linux, Ubuntu, Debian, and more.
I help Businesses scale with AI x SEO x (authentic) Content that revives traffic and keeps leads flowing | 3,000,000+ Average monthly readers on Medium | Sr Technical Writer @ DigitalOcean | Ex-Cloud Consultant @ AMEX | Ex-Site Reliability Engineer(DevOps)@Nutanix
With over 6 years of experience in tech publishing, Mani has edited and published more than 75 books covering a wide range of data science topics. Known for his strong attention to detail and technical knowledge, Mani specializes in creating clear, concise, and easy-to-understand content tailored for developers.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Step 3 is giving me the following error - curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
What if I merely have macOS Sierra? What difference will that make? What can I do to make this work with Sierra?
Update needed for Step 5:
brew cask install <program>
got updated. Now you install Desktop Programms with brew install --cask <program>
.
I hope the article may be updated, because it is super helpful for a System setup.
Thank you very much for the guide. Really a clear explanation. Done with a MacBook Pro M1 on MacOS Monterey.
This comment has been deleted
I’ve followed this guide till:
// Add Homebrew's executable directory to the front of the PATH
export PATH=/usr/local/bin:$PATH
brew installation script defaulted to the following path
export PATH=/opt/homebrew/bin:$PATH
if it’s your case make sure to take note when brew prompt it during installation.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.