homebrew with M1 macbook air error when starting terminals
Asked Answered
T

6

16

I installed homebrew 3.0.0 on my M1 MBA.

However, every session including iterm2 terminal and tmux shows this error message:

/Users/jinrae/.zprofile:1: no such file or directory: opt/homebrew/bin/brew

In my case, it does not harm functionality at least in my usage pattern.

Anyhow, how can I get rid of this message?

Trustless answered 9/2, 2021 at 4:26 Comment(2)
I would check the contents of the .zprofile file. Homebrew is supposed to be installed at /opt/homebrew/bin/brew. That path you are getting an error for is different (missing the leading /). So it's probably not able to load that profile correctly. Though your homebrew itself may be working correctlyUlyanovsk
@Ulyanovsk I think that your idea is reasonable. In .zprofile, only a single line was written as eval $(opt/homebrew/bin/brew shellenv). I added / in front of opt but it does not resolve the issue.Trustless
O
22

I got this error because I installed brew on the Rosetta version of terminal to install packages, that are not yet M1 compatible.

To get rid of this message i opened my .zprofile with nano .zprofile.

The first line was

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

And i simply put a # before this line to comment it out and the message was gone.

Oligopoly answered 17/8, 2021 at 17:47 Comment(1)
This was correct for me. Brew doctor was telling me it should be reinstalled because it was in /opt? instead of local or something. When I reinstalled it still had the old .zprofile line and the new one so commenting it out fixed the problem.Cowfish
T
9

To @sedavidw, /opt/homebrew/bin contains .keepme without contents:

/Users/jinrae/.zprofile:1: no such file or directory: opt/homebrew/bin/brew
➜  bin pwd
/opt/homebrew/bin
➜  bin la
total 0
-rw-r--r--  1 jinrae  admin     0B Feb  9 11:04 .keepme

EDIT: I read an article saying that homebrew is installed in /opt/homebrew/bin in M1 Mac whereas it is installed in /usr/local in Intel Mac. I'm trying to reinstall homebrew for M1 Mac now.

EDIT2: I solved the problem. It was due to for what homebrew is installed. As I heard, homebrew is installed in /usr/local for Intel Mac and /opt/homebrew/bin for M1 Mac.

I reinstalled homebrew with

/bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/nrubin29/bea5aa83e8dfa91370fe83b62dad6dfa/raw/48f48f7fef21abb308e129a80b3214c2538fc611/homebrew_m1.sh)"

which is slightly different from that in the official site (at least to me). Anyhow, newly installed homebrew is located in /opt/homebrew/bin and the problem has been solved.

Trustless answered 9/2, 2021 at 12:43 Comment(0)
A
9

If you are using an Intel Mac, as mentioned above, Homebrew gets installed on /usr/local. Therefore, modify your .zprofile file (located in users/<username>) to use the correct path. Here is content of .zprofile:

eval "$(/usr/local/Homebrew/bin/brew shellenv)"
Action answered 9/11, 2021 at 19:10 Comment(0)
S
2

Try this

Open your terminal and run following command

sudo nano ~/.zprofile

replace the eval "$(/opt/homebrew/bin/brew shellenv)" with eval "$(/usr/local/bin/brew shellenv)" and save.

Sanborn answered 13/12, 2023 at 9:16 Comment(0)
F
0

To Fix Type nano .zprofile then delete all of the stuff then do ⌃X then press return

Fraction answered 2/10, 2021 at 7:34 Comment(0)
G
0

I have the M1 Mac and it was installed in /opt/homebrew/...

I opened /Users/~username~/.zprofile and it had two lines.

First line was:

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

Second like was:

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

I just commented out the first line which doesn't actually have the </opt/> in the address. It's asking for a $opt, and then the address. So commenting out that line removed the location error and just read the correct line. So it doesn't show the error anymore when opening the terminal.

Globule answered 27/6, 2022 at 15:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.