Homebrew 更换阿里云镜像源

你可能有过这样糟糕的经历,当你满心欢喜的敲下 “brew install 应用名称”,静静的等待安装结果的时候,Homebrew在 Updating Homebrew卡死了。

Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。

使用 阿里云 的 Homebrew 镜像源进行加速

如果你没有更换过镜像源,执行 brew 命令安装应用的时候,跟以下 3 个仓库地址有关:

  • brew.git
  • homebrew-core.git
  • homebrew-bottles

通过以下操作将这 3 个仓库地址全部替换为 阿里云 提供的地址

更换 brew.git

1
2
3
cd "$(brew --repo)"

git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

更换 homebrew-core.git

1
2
3
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

执行上述命令之后,请执行 brew update 命令

此时可以执行 brew config 命令,查看配置信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
HOMEBREW_VERSION: 2.1.5
ORIGIN: https://mirrors.aliyun.com/homebrew/brew.git
HEAD: db58b9f41b70a331dbe9b8371527a23e8ddcc718
Last commit: 2 days ago
Core tap ORIGIN: https://mirrors.aliyun.com/homebrew/homebrew-core.git
Core tap HEAD: 5e2a0aaa5fb49aeb4a820ab085f0e53f4de14371
Core tap last commit: 23 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: dodeca-core 64-bit kabylake
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 11.0 build 1100
Git: 2.21.0 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_211
macOS: 10.14.5-x86_64
CLT: 11.0.0.0.1.1559496560
Xcode: N/A
CLT headers: 11.0.0.0.1.1559496560

更换 homebrew-bottles

这与你当前 macOS 系统使用的 shell 版本有关系,执行以下命令查看 Shell版本:

1
echo $SHELL

根据版本不同,会输出2种结果,/bin/zsh 或 /bin/bash,根据类型进行操作即可

/bin/zsh 结果

1
2
3
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc

source ~/.zshrc

/bin/bash 结果

1
2
3
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile

source ~/.bash_profile

到这里,更换 Homebrew 默认源的所有操作啦,尽情地去 brew install 吧!是不是很简单呢?

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值