Homebrew的安装指南

1. 官方安装

🔗 Homebrew官网

终端输入命令:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

要么是连接失败,要么是网速超慢导致失败。

2. 镜像安装

  1. 从上面命令的链接中下载脚本​ 🔗 install.sh

  2. 打开脚本文件,修改远程仓库地址:

    # 找到如下代码
    BREW_REPO="https://github.com/Homebrew/brew"
    # 注释掉替换为中科大镜像
    BREW_REPO="https://mirrors.ustc.edu.cn/brew.git"
    # 或清华大学镜像
    BREW_REPO="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
    
  3. 终端执行该脚本(可通过拖入终端窗口的方式)

  4. 中途会卡住:

    ==> Tapping homebrew/core Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
    

    因为 homebrew-core 的 git 源没有替换。
    此时中断命令的执行。(或许是 Command + C ?)

  5. 从中科院的镜像地址克隆 homebrew-core:

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git clone git://mirrors.ustc.edu.cn/homebrew-core.git
    
  6. 更新 homebrew:

    brew update
    
  7. 检查一下:

    brew doctor
    
  8. 安装完成验证:

    # 查看版本
    brew -v
    # 查看配置信息
    brew config
    

3. 设置镜像

brewhomebrew-core 是必需项目,homebrew-caskhomebrew-bottles 按需设置。
cask 软件仓库:提供 macOS 应用和大型二进制文件。
bottles 源:Homebrew 预编译二进制软件包。

brew

# 进入本地仓库目录
cd "$(brew --repo)"
# 查看远程仓库(可选操作)
git remote -v
# 设置远程仓库为中科大镜像
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 更新
brew update

清华镜像:https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
🔗 Homebrew/Linuxbrew 镜像使用帮助

homebrew-core

# 进入本地仓库目录
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 查看远程仓库(可选操作)
git remote -v
# 设置远程仓库为中科大镜像
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 更新
brew update

清华镜像:https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

homebrew-cask

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

homebrew-bottles

临时设置:

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

长期替换:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

恢复

cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

cd "$(brew --repo)/Library/Taps/caskroom/homebrew-cask"
git remote set-url origin https://github.com/Homebrew/homebrew-cask.git

brew update

参考文档:
🔗 mac下镜像飞速安装Homebrew教程
🔗 Mac HomeBrew国内镜像安装方法

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值