[Solved] bash brew command not found | How to install brew on MacOS?

[Solved] bash brew command not found | How to install brew on MacOS?

Are you getting the below error while installing any package on your Mac?

-bash: brew: command not found

This error occurs when your system is not able to recognize the ‘brew’ command. Mainly, two reasons…

Homebrew is not installed on your system or it is not properly configured.

Homebrew is the widely used package manager for macOS. So this is the first software that should be installed on your system before you install any package.

Install the Homebrew package manager on macOS

Here is the simple command to install the Homebrew package manager on your macOS.

Open the Mac terminal and execute the below command.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Make sure your internet connection is turned on while executing this command.

Mac Terminal is the most powerful tool for developers.

Configure brew path

Once you install Homebrew, you will see the message something like this…

==> Next steps:
- Run this command in your terminal to add Homebrew to your PATH:
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started

As mentioned in the above message, execute the next step.

eval "$(/opt/homebrew/bin/brew shellenv)"

It will set the path for homebrew/brew.

To verify if the brew path is configured or not, check $PATH content using the following command.

cat "/usr/local/bin:$PATH"

You will see the brew path registered.

To verify the brew installation and configuration, execute the following brew doctor command in your macOS terminal.

brew doctor

Next time when you run any brew command, you will not encounter with brew: command not found error.

Now, you are free. Go and install any package you want using Brew.

I always prefer Mac over PC for all my development. If you are a developer, check the following tutorials that may help you to fasten your development.

Happy brewing 😀

Leave a Reply

Your email address will not be published. Required fields are marked *