在Mac(M1芯)上安装 Homebrew及Warning解决20230328

一、安装软件
去https://brew.sh/
在主页上找到上图的代码复制到终端(我直接放下面了 更新日期2023年3月28日)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
3. 会出现以下内容,直接按键盘上的RETURN
或ENTER
按钮继续:
==> 正在检查 `sudo` 访问权限(可能需要您的密码)...
(电脑锁屏的密码,盲输)
密码:
==> 该脚本将安装:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/ homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
==> 以下新目录将是创建:
/opt/homebrew/bin
/opt/homebrew/etc
/opt/homebrew/include
/opt/homebrew/lib
/opt/homebrew/sbin
/opt/homebrew/share
/opt/homebrew/var
/opt/homebrew/opt
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/var/homebrew
/opt/homebrew/var/homebrew/linked
/opt/homebrew/Cellar
/opt/homebrew/Caskroom
/opt/homebrew/Frameworks按 RETURN/ENTER 继续或任何其他键中止:
4. 根据网速,可能需要一些时间。
若出现警告,则进入第二部分。(M1芯片一般会警告)
(前省略)
···
HEAD is now at 12e7787eb Merge pull request #15058 from apainintheneck/fix-readall-no-simulate
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; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/wangqian/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh
翻译(渣机翻帮助理解):
(前省略)
警告:/opt/homebrew/bin 不在您的路径中。
有关如何为 Homebrew 配置 shell 的说明,
请参见下面的“后续步骤”部分。
==> 安装成功!==> Homebrew 启用了匿名聚合公式和木桶分析。
在此处阅读分析文档(以及如何选择退出):https:
//docs.brew.sh/Analytics
尚未发送任何分析数据(在此安装运行期间也不会发送任何数据)。==> Homebrew 完全由无偿志愿者运行。请考虑捐赠: https:
//github.com/Homebrew/brew#donations==> 后续步骤:
- 在您的终端中运行这两个命令以将 Homebrew 添加到您的 PATH 中:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/yourname/.zprofile
eval " $(/opt/homebrew/bin/brew shellenv)"
- 运行 brew help 开始
- 更多文档:
https://docs.brew.sh
二、问题说明及操作:
1.说明:类似于windows系统下的配置环境变量。
要按照“后续步骤”并将 Homebrew 添加到 PATH,以便brew
从终端的任何位置运行。如果不这样做,每次运行时都会看到brew
:
$ brew install something
zsh:找不到命令:brew
2、操作
粘贴入终端并运行:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/<willshowyouruserdirectory>/.zprofile
再粘贴入终端并运行:
eval "$(/opt/homebrew/bin/brew shellenv)"
完成。