当前位置: 首页 > article >正文

更换Homebrew 源

以下是查看和修改 Homebrew 源的详细步骤,适用于需要切换到国内镜像以加速下载的场景:

1. 查看当前 Homebrew 源

# 查看 brew 主仓库地址
git -C "$(brew --repo)" remote get-url origin# 查看 homebrew-core 仓库地址
git -C "$(brew --repo homebrew/core)" remote get-url origin# 查看 homebrew-cask 仓库地址(如安装了 cask)
git -C "$(brew --repo homebrew/cask)" remote get-url origin

2. 修改为国内镜像源(以中科大镜像为例)

# 设置 brew 主仓库
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git# 设置 homebrew-core 仓库
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git# 设置 homebrew-cask 仓库(可选)
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git# 刷新缓存
brew update

3. 其他国内镜像源选项

  • 清华大学镜像

    # brew 主仓库
    git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git# homebrew-core
    git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git# homebrew-cask
    git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
    
  • 阿里云镜像

    # brew 主仓库
    git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git# homebrew-core
    git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
    

4. 恢复为官方源

# brew 主仓库
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git# homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git# homebrew-cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

5. 验证修改是否成功

再次运行步骤 1 的命令,确认输出的仓库地址已变更为所选镜像源。

注意事项

  1. 中科大镜像限制:中科大镜像仅支持 macOS 和 Linux 系统,不支持 Windows。
  2. 环境变量影响:如果设置了 HOMEBREW_BREW_GIT_REMOTEHOMEBREW_CORE_GIT_REMOTE 环境变量,可能会覆盖手动设置的源。检查并删除这些环境变量:
    unset HOMEBREW_BREW_GIT_REMOTE
    unset HOMEBREW_CORE_GIT_REMOTE
    
  3. 更新问题:切换镜像后若遇到更新失败,可尝试清除缓存并重新更新:
    brew cleanup
    brew update --force
    

根据网络情况选择合适的镜像源,国内推荐使用中科大或清华的镜像。

http://www.lryc.cn/news/2394152.html

相关文章:

  • 人工智能在智能供应链中的创新应用与未来趋势
  • 鸿蒙OSUniApp自定义手势识别与操作控制实践#三方框架 #Uniapp
  • LLM优化技术——Paged Attention
  • 推荐几个不错的AI入门学习视频
  • 采用Bright Data+n8n+AI打造自动化新闻助手:每天5分钟实现内容日更
  • Real SQL Programming
  • Sentinel限流熔断机制实战
  • Java 数据处理 - 数值转不同进制的字符串(数值转十进制字符串、数值转二进制字符串、数值转八进制字符串、数值转十六进制字符串)
  • 79. 单词搜索-极致优化,可行性剪枝和顺序剪枝
  • ICDMC 2025:创新媒体模式,迎接数字时代的挑战
  • 深入解析C#多态性:基类引用、虚方法与覆写机制
  • SoftThinking:让模型学会模糊思考,同时提升准确性和推理速度!!
  • C++中 newdelete 与 mallocfree 的异同详解
  • 晨控CK-UR08与欧姆龙PLC配置Ethernet/IP通讯连接操作手册
  • STM32入门教程——LED闪烁LED流水灯蜂鸣器
  • 鸿蒙OSUniApp 实现的数据可视化图表组件#三方框架 #Uniapp
  • Tornado WebSocket实时聊天实例
  • HarmonyOS鸿蒙与React Native的融合开发模式以及能否增加对性能优化的具体案例
  • 化学分析原理。
  • 开源即战力!从科研到商用:Hello Robot 移动操作机器人Stretch 3多模态传感融合(RGB-D/激光/力矩)控制方案
  • 元胞自动机(Cellular Automata, CA)
  • 智能手表单元测试报告(Unit Test Report)
  • 微深节能 码头装卸船机定位与控制系统 格雷母线
  • 基于matlab遗传算法和模拟退火算法求解三维装箱优化问题
  • 在Spring Boot中集成Redis进行缓存
  • Python实现P-PSO优化算法优化循环神经网络LSTM分类模型项目实战
  • OSG编译wasm尝试
  • Scratch节日 | 龙舟比赛 | 端午节
  • Ubuntu搭建DNS服务器
  • electron开发百度桌面应用demo及如何打包应用