How to install homebrew on M1 mac

I just got a new Mac, the M1 Macbook pro and I am trying to install homebrew, but every time I finish installing it, it tells me that it was not written to the path, and then when I try the advised whatever to add to the path, nothing happens and the terminal or whatever does not recognize the command at all, as if it isn't installed.

This worked perfectly fine on my old Intel mac, and there is some step or whatever - I don't know anything, and I am tired and I don't understand how to install this at all, but hte path is supposed to be different for Apple silicon macs but nothing i read helps at all.


Solution 1:

Homebrew installation on apple silicon, step by step:

  • Open a terminal window (it should be zsh)
  • Run this command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

In my case, installation show me errors, I just installed again, and then show: Installation successful!, and warning: /opt/homebrew/bin is not in your PATH

  • Then create .zshrc on home directory (If it was not created yet). Just run on terminal:
touch .zshrc
  • Then open it to edit with TextEdit (Is a hidden file. You can show hidden files with shift + command + . )

  • Add this line at the end of .zshrc

export PATH=/opt/homebrew/bin:$PATH
  • Run this command in terminal to make this available:
source ~/.zshrc
  • Now just run this command to be sure that everything is working:
brew help

This works for me to path homebrew permanently.

Or do:

- Add Homebrew to your PATH in ~/.zprofile:
    echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zprofile
    eval $(/opt/homebrew/bin/brew shellenv)

Solution 2:

Seems Touch, source and export not required now. Run the below command in terminal

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

and follow the instructions showing in terminal itself. shows as follows:

==> Next steps:
 Run these two commands in your terminal to add Homebrew to your PATH:

    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/xxx/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"

Then, brew help

Solution 3:

open the terminal and copy below command

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

create new empty file with touch

touch .zshrc

now open the file with vim editor

vim .zshrc

now enter i to start edit mode and write

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

then press esc and type :wq

now we setup brew successfully for permanently to test enter

brew or brew help

Solution 4:

Go To the home brew webpage

https://brew.sh/

copy the script provided under Install Homebrew

Open Terminal via spotlight search

Then open the terminal in the using the spotlight search by pressing the command + spacebar

now in the terminal paste the script which was copied from the homebrew site

it will ask to click return button after some time so don't worry after successful installation the brew won't work as for M1 Chip MacBook air.

It will show some warning for the path i.e. warning: /opt/homebrew/bin is not in your PATH

==>Now on the same terminal we will create the file .zshrc in the home directory

So Run the command to create this directory i.e.

touch .zshrc

Now we will open the home directory

To open home directory we will open the finder from the dock and make sure its the active application

now in the finder app we will press button to open the home directory i.e. command+shift+H

After this finder will open the home directory

Now since the .zshrc is a hidden file as we created it using the terminal above

Now to access the hidden file press the button i.e. shift + command + .

After this locate the .zshrc file and click to edit with Text Editor option

Set the path in .zshrc file

Now at the end of the line paste this -

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

Now we will make this file available

So type paste this code in the terminal

source ~/.zshrc

After this command run one more command on the terminal to check if the howebrew is working fine

brew

On typing this you will get to know that home brew is now working!!

Now do what ever you want to do using brew either install git or any other things which you want....

Have a Good Day Guys!!