我在我的 M1 MBA 上安装了 homebrew 3.0.0。
但是,包括 iterm2 终端和 tmux 在内的每个会话都会显示此错误消息:
/Users/jinrae/.zprofile:1: no such file or directory: opt/homebrew/bin/brew
就我而言,至少在我的使用模式中,它不会损害功能。
无论如何,我怎样才能摆脱这个消息?
我收到此错误是因为我在 Rosetta 版本的终端上安装了brew 来安装尚未与 M1 兼容的软件包。
为了摆脱这条消息,我用
.zprofile
打开了我的 nano .zprofile
。
第一行是
eval“$(/opt/homebrew/bin/brew shellenv)”
我只是在这一行之前加了一个 # 将其注释掉,消息就消失了。
致@sedavidw,
/opt/homebrew/bin
包含.keepme
但不含内容:
/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
编辑:我读到一篇文章说,
homebrew
安装在M1 Mac中的/opt/homebrew/bin
中,而它安装在Intel Mac中的/usr/local
中。我现在正在尝试为 M1 Mac 重新安装自制程序。
EDIT2:我解决了问题。这是由于安装了自制软件。据我所知,自制软件安装在 Intel Mac 的
/usr/local
和 M1 Mac 的 /opt/homebrew/bin
中。
我重新安装了自制软件
/bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/nrubin29/bea5aa83e8dfa91370fe83b62dad6dfa/raw/48f48f7fef21abb308e129a80b3214c2538fc611/homebrew_m1.sh)"
这与官方网站上的略有不同(至少对我来说)。 不管怎样,新安装的自制程序位于
/opt/homebrew/bin
,问题已解决。
如果您使用的是 Intel Mac,如上所述,Homebrew 将安装在
/usr/local.
上,因此,请修改您的 .zprofile
文件(位于 users/<username>
中)以使用正确的路径。以下是.zprofile
的内容:
eval "$(/usr/local/Homebrew/bin/brew shellenv)"
我有 M1 Mac,它安装在 /opt/homebrew/...
我打开/Users/~用户名~/.zprofile,它有两行。
第一行是:
eval "$opt/homebrew/bin/brew shellenv"
第二个喜欢的是:
eval "$(/opt/homebrew/bin/brew shellenv)"
我只是注释掉了第一行,该行实际上在地址中没有 。它要求 $opt,然后然后 地址。因此,注释掉该行可以消除位置错误,只需读取正确的行即可。所以打开终端时不再显示错误。
试试这个
打开终端并运行以下命令
sudo nano ~/.zprofile
将
eval "$(/opt/homebrew/bin/brew shellenv)"
替换为 eval "$(/usr/local/bin/brew shellenv)"
并保存。
修复类型
nano .zprofile
然后删除所有的东西
然后做⌃X
然后按return