使用国内源安装brew并更改源

本文介绍了如何在Mac上通过国内镜像快速安装Brew,以及如何将Brew的源切换到国内,以提高安装和更新效率。详细步骤包括下载install文件,修改源地址,安装Brew,更新PATH变量,验证安装,以及后续的源切换操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

## 在mac上安装brew时,如果使用官方推荐的方式,会耗费很长时间,并且也不一定能成功,这样,你就会感觉很蛋疼,下面是本人使用国内镜像安装brew的过程。

一、安装brew

1、将brew的install文件下载本地

$ cd

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

2、修改install文件的镜像源

$ vim brew_install 

#BREW_REPO = "https://github.com/Homebrew/brew”.freeze

#CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze

BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze

CORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git”.freeze

#就是“BREW_REPO”和“CORE_TAP_REPO”这两项,将其修改为清华的镜像

3、安装

$ /usr/local/bin/ruby ~/brew_install

4、修改PATH变量

$ vim /etc/profile

# 加入下面这一行

export PATH=/usr/local/bin:$PATH

$ source /etc/profile

5、验证

$ brew doctor

6、安装wget

$ brew install wget 

二、修改brew的源为国内的源

$ cd "$(brew --repo)"

$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

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

$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

$ brew update

 

 

 

 

 

 

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值