How to Install Homebrew in macOS

homebrew

We often struggle to install the Homebrew package manager in our mac. Although it is a simple installation but it always gives surprises. I have also done it earlier couple of times, and had different experience for macOS.

Its been a bit tricky, but anyways it’s simple. we can follow the below steps and it will work for everyone.

How to Install Homebrew?

Homebrew can be installed via command line or by using .pkg file. (Download here)

Install using command Line:

Copy the code below and paste it in the command line and press enter.

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

It will start downloading and will take a while to finish. Now ideally right after the above step we should be able to get it and we can use the “brew” command further. But wait!. here is the trick. macOS doesn’t add the new path of the ‘homebrew bin’ to existing system path.

For confirmation first check the Homebrew version. Run the below command to check the installed version.

brew --version

If path is set properly then we will get the installed version in result for ex : (Homebrew 4.4.32)

If path is not set then we will get the error as (brew: command not found)

brew: command not found

Path can be set as follows:

We have to add the path “/opt/homebrew/bin” to the current path. You can check the current path by hitting the following command.

echo $PATH

Copy and paste the path as below command which we have received with above:

export PATH=$PATH:/opt/homebrew/bin

After that, check the PATH variable again and make sure the Homebrew path is added in to the existing path list.

Now to make it 100% sure, close all terminals and open a fresh one and see if brew is installed. Just run <brew help>

Even if it is not working, please check if you are using the zsh or bash terminal. switch to bash terminal and follow the process again. and it will works!

Leave a Reply

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

Back To Top