macOS 安装 homebrew 国内的使用者有两个错误比较常见:
error: RPC failed; curl 28 Failed to connect to github.com port 443 after 75000 ms: Couldn't connect to server
fatal: expected flush after ref listing
Warning: Trying again in 2 seconds: /usr/bin/git fetch --quiet --progress --force origin
error: RPC failed; curl 28 Failed to connect to github.com port 443 after 75000 ms: Couldn't connect to server
fatal: expected flush after ref listing
与
国内镜像安装是比较稳妥的方式,可选择镜像源主要有三个:
// 清华大学
Tsinghua University: https://mirrors.tuna.tsinghua.edu.cn
// 中科大
USTC (University of Science and Technology of China): https://mirrors.ustc.edu.cn
// 阿里云
Alibaba Cloud: https://mirrors.aliyun.com
以下以清华大学为例,介绍安装过程
第一步
需要准备
对于 macOS 用户,系统自带 bash、git 和 curl,在命令行输入 xcode-select --install 安装 CLT for Xcode 即可。
第二步
设置环境变量(临时)
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_INSTALL_FROM_API=1
第三步
安装(默认)
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
有环境的情况下,直接用 GitHub 下载
/bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install.sh)"
第四步
删除 brew 安装文件,也可以不操作
rm -rf brew-install
安装过程提示
==> /usr/bin/sudo /bin/mkdir -p /etc/paths.d
==> /usr/bin/sudo tee /etc/paths.d/homebrew
/opt/homebrew/bin
==> /usr/bin/sudo /usr/sbin/chown root:wheel /etc/paths.d/homebrew
==> /usr/bin/sudo /bin/chmod a+r /etc/paths.d/homebrew
HOMEBREW_BREW_GIT_REMOTE set: using https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git as the Homebrew/brew Git remote.
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:20fa657858e44a4b39171d6e4111f8a9716eb62a78ebbd1491d94f90bb7b830a
########################################################################################### 100.0%
==> Pouring portable-ruby-3.4.5.arm64_big_sur.bottle.tar.gz
==> 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 commands in your terminal to add Homebrew to your PATH:
echo >> /Users/username/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/username/.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 non-default Git remotes for Homebrew/brew and Homebrew/homebrew-core.' >> /Users/username/.zprofile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"' >> /Users/username/.zprofile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"' >> /Users/username/.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
- Further documentation:
https://docs.brew.sh
对仓库的配置,参考清华的源
homebrew | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
编辑
vim ~/.bash_profile
可见配置信息。

851

被折叠的 条评论
为什么被折叠?



