欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 手游 > 【Mac OS 安装 Homebrew】

【Mac OS 安装 Homebrew】

2025/9/17 14:20:41 来源:https://blog.csdn.net/ppblackboy/article/details/144323996  浏览:    关键词:【Mac OS 安装 Homebrew】

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 Homebrewcan 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/.zprofileecho 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/dd/.zprofileeval "$(/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/.zprofileecho 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"' >> /Users/dd/.zprofileecho 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"' >> /Users/baixiaodong/.zprofileexport 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 来安装需要的软件了。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词