【Mac OS 安装 Homebrew】
Homebrew 是一个用于 macOS 的包管理工具,它极大地简化了软件的安装和管理过程。通过Homebrew,开发者和普通用户可以在Mac上轻松地安装和使用大量的开源工具和应用程序。
如果你需要使用 wget ,但是系统并未安装,那么通过 brew install wget 安装即可。但是系统如果没有安装 brew ,执行命令就提示 ```zsh: command not found: brew ``
要安装 brew 那么现在浏览器打开 https://brew.sh ,进入它的网站查看安装方式,目前提供两种安装方式。
使用命令安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
但是这个命令是不是一次可以执行成功,如果你遇到同样的问题,按着解决就可以,如果没有遇到那就恭喜你你太幸运了。
遇到错误
error: RPC failed; curl 92 HTTP/2 stream 5 was not closed cleanly: CANCEL (err 8)
==> Downloading and installing Homebrew...
remote: Enumerating objects: 287351, done.
remote: Counting objects: 100% (707/707), done.
remote: Compressing objects: 100% (388/388), done.
error: RPC failed; curl 92 HTTP/2 stream 5 was not closed cleanly: CANCEL (err 8)
error: 6440 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
Failed during: /usr/bin/git fetch --quiet --progress --force origin
解决方案
在 终端(Terminal)输入一下命令
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
再次执行
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
看到开始正常下载安装了,如果日志显示一切正常,并提示安装成功,再新终端中执行 brew 命令不再出现 command not found brew ,那么再次恭喜你。
我这里安转是一波三折,出现了告警
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!
==> Next steps:
- Run these commands in your terminal to add Homebrew to your PATH:
echo >> /Users/dd/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/dd/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run these commands in your terminal to add the non-default Git remotes for Homebrew/brew and Homebrew/homebrew-core:
echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /Users/dd/.zprofile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"' >> /Users/dd/.zprofile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"' >> /Users/baixiaodong/.zprofile
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
- Run brew help to get started
看提示是 /opt/homebrew/bin is not in your PATH, 应该安装时没有使用 sudo,如果有 sudo 我猜可以直接成功使用,大家安装可尝试。
解决方案
看上面命令的提示执行 Next steps 里的内容就好。
安装包安装
下载地址:https://github.com/Homebrew/brew/releases/tag/4.4.10
找到 pkg 安装包下载,像 windows 上安装软件一样,根据提示安装就好。
接下来你就可以使用 brew install 来安装需要的软件了。
原文地址:https://blog.csdn.net/ppblackboy/article/details/144323996
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!