brew 镜像_HomeBrew下载速度慢?尝试切换到镜像源吧

053687297333695ca143047b0182d34f.png

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

HomeBrew是一个很棒的仓库,但是由于网络复杂等原因,尝尝无法使用brew下载包文件,本文提供两种国内镜像源,不妨试试。

1. 中科大镜像源

需要替换为中科大源,请执行以下代码:

cd "$(brew --repo)"git remote set-url origin git://github.com/Homebrew/brewcd "$(brew --repo)"git remote set-url origin https://mirrors.ustc.edu.cn/brew.gitcd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.gitcd brew updateecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profilesource ~/.bash_profile

2. 清华大学源

需要替换为清华大学源,请执行以下代码:

cd "$(brew --repo)"git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.gitcd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.gitcd brew updateecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profilesource ~/.bash_profile

3. 使用homebrew-science或者homebrew-python

使用如下代码切换:

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-science"git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-science.gitcd "$(brew --repo)/Library/Taps/homebrew/homebrew-python"git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-python.gitcdbrew update

4. 切回官方源

有时候,上述中科大源或清华源失效或宕机,需要切换回官方源:

首先下载brew_instal文件

cd ~curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install

编辑brew_instal文件

HOMEBREW_PREFIX = "/usr/local".freezeHOMEBREW_REPOSITORY = "/usr/local/Homebrew".freezeHOMEBREW_CACHE = "#{ENV["HOME"]}/Library/Caches/Homebrew".freezeHOMEBREW_OLD_CACHE = "/Library/Caches/Homebrew".freezeBREW_REPO = "https://github.com/Homebrew/brew".freeze#BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freezeCORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze#CORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze

注释掉:

BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freezeCORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze

修改为:

BREW_REPO = "https://github.com/Homebrew/brew".freezeCORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze

安装,运行修改了的brew_install文件。

/usr/bin/ruby ~/brew_install 

替换homebrew默认源

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

在Mac OS X 10.11系统以后,/usr/local/等系统目录下的文件读写是需要系统root权限的,以往的Homebrew安装如果没有指定安装路径,会默认安装在这些需要系统root用户读写权限的目录下,导致有些指令需要添加sudo前缀来执行。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值