美文网首页
Homebrew源

Homebrew源

作者: 镜像 | 来源:发表于2022-07-11 16:19 被阅读0次

一、什么是Homebrew的源?

其实就是一个git的url,对应的是git仓库。
每次通过Homebrew安装软件,Homebrew会根据源,会比对、下载(或者merge)源仓库到本地,然后根据要下载的软件找到对应的xxx.rb文件,然后再根据rb文件中内容一步步的校验、下载、安装软件。

1.Homebrew原始源

代码如下(示例):

# homebrew源
https://github.com/Homebrew/brew.git
# homebrew-core源
https://github.com/Homebrew/homebrew-core.git
# homebrew-cask源
https://github.com/Homebrew/homebrew-cask.git

二、替换Homebrew的源

1.替换为清华的源

代码如下(示例):

# 替换brew.git源
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替换 homebrew-core.git源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 替换 homebrew-cask.git源
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

其实替换这三个源就可以了,另外就是homebrew-bottles,这个配置个HOMEBREW_BOTTLE_DOMAIN环境变量,不过好像不配置也没啥问题:

# 使用bash的话
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

# 使用zsh的话
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

2.替换为中科大的源
代码如下(示例):

# brew.git源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# homebrew-core.git源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# homebrew-cask.git源
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# 配置homebrew-bottles
## bash用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
## zsh用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

3.复核与还原
如果想重置为官方的源,可以如下操作:

# brew.git源
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
# homebrew-core.git源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core
# homebrew-cask.git源
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask
//最后执行brew update来尝试一下看是否速度更快。

相关文章

  • node.js安装

    一、替换Home-brew源 替换Homebrew默认源 替换Homebrew-core源 二、通过Homebre...

  • 替换重置Homebrew源

    做个记录 替换Homebrew Bottles源: 参考:替换Homebrew Bottles源 在中科大源失效或...

  • Brew 源的替换

    替换 USTC 镜像 1、替换Homebrew源 重置: 2、替换homebrew-core源 重置: 3、替换h...

  • homebrew 源

    2021.3.5昨天用了下腾讯软件源[https://mirrors.cloud.tencent.com/], 感...

  • Homebrew源

    一、什么是Homebrew的源? 其实就是一个git的url,对应的是git仓库。每次通过Homebrew安装软件...

  • MacOS 解决Homebrew卡慢问题

    一、替换Homebrew国内源(推荐) 中科大源 清华源: 官方源: coding源 二、更换homebrew-b...

  • 安装HomeBrew

    一、安装HomeBrew 1.1 官网安装方法 1.2 更改下载源解决上述安装问题 1.3 Homebrew换源 ...

  • mac os 终端命令记录

    1、Homebrew更新太慢,更换源 当以上镜像失败后,可重置回原设置 Homebrew Bottles源处理 2...

  • Mac 查看SSD写入量/损耗

    前置条件:安装过HomeBrew 换源安装HomeBrew[https://www.jianshu.com/p/a...

  • 2020-01-20 Homebrew换源和更新

    update Homebrew 1.更新源 2.修复源 3.重置源

网友评论

      本文标题:Homebrew源

      本文链接:https://www.haomeiwen.com/subject/vfpnbrtx.html