198

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.

ema1982
  • 2,089
  • 2
  • 5
  • 4

11 Answers11

505

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)
Lena Bru
  • 13,521
  • 11
  • 61
  • 126
Camilo Lizarazo Olaya
  • 5,151
  • 1
  • 5
  • 5
  • 6
    This worked . This is related to the alternative install on the described on the homebrew site. "This script installs Homebrew to its preferred prefix (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon) so that you don’t need sudo when you brew install. It is a careful script; it can be run even if you have stuff installed in /usr/local already. It tells you exactly what it will do before it does it too. You have to confirm everything it will do before it starts." https://docs.brew.sh/Installation – Rodrigo Lopez Guerra Jun 21 '21 at 14:05
  • This worked in the first go. While i tried closing the terminal and checking _ brew services it responds with not found brew command. could be export issue. – KRIPA SHANKAR JHA Aug 22 '21 at 11:30
  • 4
    for this line >"Then open it to edit with TextEdit (Is a hidden file. You can show hidden files with shift + command + . )" I have used this: ```open .zshrc``` You may consider if you want only work with terminal commands Thank you very much for this great work – A. Yasar G. Nov 20 '21 at 22:51
  • is there a way to check if the path is correct without having to modify it? i.e. if the install worked correctly? – Charlie Parker Feb 07 '22 at 23:33
  • actually if you read the output of brew it tells you how to put it in your path. Do `eval "$(/opt/homebrew/bin/brew shellenv)"` – Charlie Parker Feb 07 '22 at 23:34
  • nvm, you still have to do that update in your path. Weird! – Charlie Parker Feb 07 '22 at 23:38
  • I think the right command is ```- Add Homebrew to your PATH in ~/.zprofile: echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zprofile eval $(/opt/homebrew/bin/brew shellenv)``` correcting it. – Charlie Parker Feb 08 '22 at 00:58
  • Hi there, I am getting this error when I am trying to install Homebrew on my new Macbook Pro: curl: (60) SSL certificate problem: self signed certificate More details here: https://curl.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above. Any idea what I can do? Any help would be greatly appreciated! – Aidenhsy Feb 19 '22 at 10:18
  • As this [post](https://unix.stackexchange.com/a/487889/498440) says, environment variable should not be manipulated in `.zshrc`(it is for interactive usage), so put it in your `.zprofile` – Steve Lau May 08 '22 at 04:50
  • If I run `brew upgrade`, I get `Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)! Please create a new installation in /opt/homebrew using one of the "Alternative Installs" from: https://docs.brew.sh/Installation You can migrate your previously installed formula list with: brew bundle dump ` –  Aug 11 '22 at 11:24
  • I've solved the problem using the terminal command pointed in the answer and then using two commands mentioned in Homebrew installation output. So my solution was the following: Open Terminal and run the following commands: 1. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 2. (echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/yuliashlykova/.zprofile 3. eval "$(/usr/local/bin/brew shellenv)" – Yulia Jun 07 '23 at 10:30
83

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

name-it
  • 2,238
  • 3
  • 19
  • 28
18
  1. Go to Homebrew and get the install command:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. When requsted in the Terminal press 'return' to finish installation

  3. After installation, the Terminal generates the next commands to be executed:

    ==> Next steps:
    Run these two commands in your terminal to add Homebrew to your PATH:  
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/$yourdevicename/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
    Run brew help to get started
    - Further documentation:
    https://docs.brew.sh
    
Sysanin
  • 1,501
  • 20
  • 27
Flavio Caduff
  • 901
  • 1
  • 10
  • 16
9

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

  • last step => - Add Homebrew to your PATH in ~/.zprofile: echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zprofile eval $(/opt/homebrew/bin/brew shellenv) – Ahmadreza May 17 '22 at 03:22
9

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!!

Nikhil Saxena
  • 107
  • 1
  • 1
5

Put this line in a .zshrc file in your default home directory.

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

lesterfernandez
  • 216
  • 3
  • 7
4

The answer given by Lena Bru and Camilo Lizarazo Olaya is the solution.

Especially the last code block

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

The complete returning on Terminal is

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!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/bohuang/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh

has been accepted by the official team of Homebrew.

I installed Homebrew to my new Macbook Pro (chip Apple M1 Pro). The installation was completed successfully, and threw out a hint which was same as the two command lines.

BoHuang
  • 109
  • 4
0

Also, you can check this short article out and doing it using aliases.

0

If you are getting the intel chip error

xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): tried: '/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libxcrun.dylib' (no such file)).

then you have to fix your command line tools (CLT). What I did is the following (solution from here):

What I suggest is to uninstall the command line tools (CLT) and re-install them the official way (source).

So do (source):

sudo rm -rf /Library/Developer/CommandLineTools

check it uninstalled, you should get an output as follows:

xcode-select -p

output

xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one (or see `man xcode-select`)

then install the command line tools (CLT) again:

xcode-select --install

then agree to it and it should download after a couple of minutes. The download should take some time. For me ~13mins.

After that your issues with PyCharm, git, brew and likely other tools will be resolved.

After you have that resolved -- which was causing me issue when trying to install brew -- do what the top answer here recommends: https://stackoverflow.com/a/67271753/1601580 which in a summary is run the bash install of brew and make sure it is in your PATH env variable properly.

Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
-1

After Installing brew

Go to root folder by opening the terminal.

type: vim .zshrc if exist. Type i to start editing the .zshrc file. add line

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

After editing, press esc and save using :wq

Then run command

exec zsh

And voila, brew is ready..

Thanks, Let me know if it helps.

Rahul Manas
  • 97
  • 1
  • 4
-5

Install Homebrew

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

InstallOpenCV You must have Python3 installed

pip3 install opencv-python
Imam Ahasan
  • 1
  • 1
  • 3