How to install Homebrew — MacOS for beginners
Source: Dev.to
Originally published on Little Coding Things
If you are making your first steps on macOS, you may have never heard of Homebrew before. Homebrew is a powerful package manager, similar to npm if you’ve worked with it before. It allows you to easily install, update, and remove software packages directly from your terminal, making it an incredibly handy tool for developers. In this post, you’ll find a step‑by‑step guide to install Homebrew on macOS.
Why is it essential to install Homebrew?
Homebrew is widely regarded as the most popular package manager for macOS. It’s the go‑to choice for developers and power users because of its simplicity and active community support.
Homebrew lets you easily get the tools and libraries you need for development or daily tasks, from developer tools like Git and Node.js to simple everyday utilities. It saves time by skipping the trouble of manual downloads and setup. It’s simple, fast, and perfect for customizing your Mac.
If you haven’t used a tool like Homebrew before, don’t overlook it — it could completely transform the way you manage software on your Mac.
Check if Homebrew is already installed
Just to make sure you haven’t already installed Homebrew in the past, let’s check it out. Open your terminal and type:
brew help
If you have it installed, you should see something like:
Example usage:
brew search TEXT|/REGEX/
brew info [FORMULA|CASK...]
brew install FORMULA|CASK...
brew update
brew upgrade [FORMULA|CASK...]
…
Otherwise you will get the following result:
command not found: brew
How to install Homebrew
Ready to install Homebrew? Here’s everything you need to know. Open your terminal (⌘ + Space and type “Terminal”) and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
What does this command do?
/bin/bash– specifies the Bash shell, ensuring the command is executed with Bash even if your default shell is something else (e.g., Zsh).-c– tells Bash to execute the command that follows in quotes.$(curl -fsSL …)– fetches the Homebrew installation script from GitHub usingcurl(a tool for transferring data).
In simple terms, the command downloads the Homebrew installer script from GitHub and immediately runs it with Bash to set up Homebrew on your system.
You will be asked for your super‑user password:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Checking for `sudo` access (which may request your password)...
Password:
After typing your password, you’ll see a prompt to press ENTER to proceed:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
…
/opt/homebrew
==> The following new directories will be created:
/opt/homebrew/bin
/opt/homebrew/etc
/opt/homebrew/include
…
/opt/homebrew/Frameworks
Press RETURN/ENTER to continue or any other key to abort:
Wait for the installation process to complete — it may take a few minutes. Once it’s done, you’ll see the message “Installation successful!”. To verify the installation, run:
brew help
If everything went well, you should see the same output as in the “Check if Homebrew is already installed” section.
Homebrew doesn’t work after installing it
If you’ve followed all the steps but still get a “command not found” error (e.g., brew help), the Homebrew binary is likely not in your PATH.
To resolve the issue, revisit the logs from the Homebrew installation script. At the end of the script you’ll typically find instructions similar to:
Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew can be found in the 'Next steps' section below.
==> Installation successful!
...
==> Next steps:
- Run these commands in your terminal to add Homebrew to your PATH:
echo >> /Users//.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users//.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Run the commands shown (adjust the path if you use a different shell configuration file, such as ~/.bash_profile or ~/.zshrc). After adding Homebrew to your PATH, restart the terminal or source the profile file, then verify again with brew help.
That’s it! You now have Homebrew installed and ready to manage packages on your macOS system. Happy coding!
Copy the last part of the Homebrew installation instructions — starting from the command that begins with echo — and paste it into your terminal. This command typically adds Homebrew to your system’s PATH.
By now, you should have Homebrew installed on your system successfully.
Congratulations! This is just the first small step on your exciting journey to mastering powerful tools and workflows as you grow your skills. If you’re exploring ways to automate parts of your development workflow next, you might find Git tools like Husky pre‑commit hooks especially helpful.
