Homebrew 镜像源配置

前言

当我们使用默认官方源时,经常会遇到以下问题

查看镜像配置

复制代码
  1. brew config
切换国内源

复制代码
  1. /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
4.0 镜像配置

温馨提示:不要使用阿里云的 Homebrew 源,好久没更新了,而且还不支持 Homebrew 4.0 的镜像源

清华大学镜像站
复制代码
  1. # homebrew 4.x 清华大学镜像 最新的 JSON API 安装方式
  2. export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
  3. export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
  4. export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
中国科学技术大学镜像源
复制代码
  1. # homebrew 4.x 中科大镜像 最新的 JSON API 安装方式
  2. export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
  3. export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
  4. export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"

如果 shell 为 zsh,也就是添加 ~/.zshrc 文件中,然后执行以下命令或重新打开窗口

复制代码
  1. source ~/.zshrc
4.x 以前镜像配置

Zsh 终端配置 (阿里云镜像源)

复制代码
  1. # 替换brew.git:
  2. cd "$(brew --repo)"
  3. git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
  4. # 替换homebrew-core.git:
  5. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
  6. git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
  7. # 应用生效
  8. brew update
  9. # 替换homebrew-bottles:
  10. echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
  11. source ~/.zshrc

恢复 Homebrew 默认配置

复制代码
  1. # 替换 brew.git
  2. cd "$(brew --repo)"
  3. git remote set-url origin https://github.com/Homebrew/brew.git
  4. # 替换 homebrew-core.git
  5. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
  6. git remote set-url origin https://github.com/Homebrew/homebrew-core.git
  7. # 应用生效
  8. brew update
  9. # 删除 homebrew-bottles:
  10. # 注释掉 .zshrc 中的 HOMEBREW_BOTTLE_DOMAIN
  11. source ~/.zshrc
相关推荐
Clarence Liu1 分钟前
redis学习 (1) 基础入门
数据库·redis·学习
天生励志12316 分钟前
Redis 安装部署
数据库·redis·缓存
北半球的夜17 分钟前
emoji 表情符号保存问题
数据库·oracle
jason成都42 分钟前
elasticsearch部署时创建用户密码
大数据·elasticsearch·jenkins
清风6666661 小时前
基于单片机的智能家居多参数环境监测与联动报警系统设计
数据库·单片机·毕业设计·智能家居·课程设计·期末大作业
煎蛋学姐1 小时前
SSM社区医院儿童预防接种管理系统84ui9(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·ssm 框架·儿童预防接种
锡兰_CC1 小时前
无缝触达,卓越体验:开启openEuler世界的任意门
服务器·网络·数据库·c++·图像处理·qt·nginx
新华经济1 小时前
合同管理系统2025深度测评:甄零科技居榜首
大数据·人工智能·科技
ttthe_MOon2 小时前
MySQL 高可用解决方案 MHA:原理、配置与实践
数据库·mysql
黑客思维者2 小时前
招商银行信用卡AI客服系统:从0到1实战笔记
大数据·人工智能·笔记