

Mac OS安装brew 并更改brew源为国内源
source link: https://www.fly63.com/article/detial/11773
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

扫一扫分享
Homebrew官方的源一般下载包之类的会很慢,所以通常我们都是用国内的镜像源来代替,这样会提高我们的效率。Homebrew主要有四个部分组成: brew、homebrew-core 、homebrew-bottles、homebrew-cask。
名称 | 说明 |
---|---|
brew | Homebrew 源代码仓库 |
homebrew-core | Homebrew 核心软件仓库 |
homebrew-bottles | Homebrew 预编译二进制软件包 |
homebrew-cask | MacOS 客户端应用 |
Homebrew国内镜像源目前主要有中科大镜像、阿里镜像、清华镜像。
首先查看自己本地的镜像源地址是什么,在命令行输入以下命令可以查询:
查看 brew.git 当前源
cd "$(brew --repo)" && git remote -v
查看 homebrew-core.git 当前源
cd "$(brew --repo homebrew/core)" && git remote -v
如果输出是下面这些,就代表不是本地镜像源,可以换成本地镜像源,这样下载会更快点。
查看 brew.git 当前源输出
origin https://github.com/Homebrew/brew.git (fetch)
origin https://github.com/Homebrew/brew.git (push)
查看 homebrew-core.git 当前源输出
origin https://github.com/Homebrew/homebrew-core.git (fetch)
origin https://github.com/Homebrew/homebrew-core.git (push)
一、切换 Homebrew 镜像源为中科大镜像源
替换brew.git:
cd "$(brew --repo)" && git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
替换homebrew-cask.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
zsh 替换homebrew-bottles镜像,Mac OS在10.15系统开始,默认的shell都换成了zsh
echo 'export HOMEBREW_BOTTLE_domAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
修改使其立即生效
source ~/.zshrc
bash 替换homebrew-bottles镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
修改使其立即生效
source ~/.bash_profile
brew update
二、切换 Homebrew 镜像源为阿里镜像源
替换brew.git:
cd "$(brew --repo)" && git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
zsh 替换homebrew-bottles镜像,Mac OS在10.15系统开始,默认的shell都换成了zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
修改使其立即生效
source ~/.zshrc
bash 替换homebrew-bottles镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
修改使其立即生效
source ~/.bash_profile
brew update
三、切换 Homebrew 镜像源为清华镜像
替换brew.git:
cd "$(brew --repo)" && git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
替换homebrew-core.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
替换homebrew-cask.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
zsh 替换homebrew-bottles镜像,Mac OS在10.15系统开始,默认的shell都换成了zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
修改使其立即生效
source ~/.zshrc
bash 替换homebrew-bottles镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
修改使其立即生效
source ~/.bash_profile
brew update
四、切换 Homebrew 镜像源为官方镜像
重置 brew.git 为官方源:
cd "$(brew --repo)" && git remote set-url origin https://github.com/Homebrew/brew.git
重置 homebrew-core.git 为官方源:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://github.com/Homebrew/homebrew-core.git
重置 homebrew-cask.git 为官方源:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://github.com/Homebrew/homebrew-cask
zsh 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置,前面加#符号就行
vi ~/.zshrc
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx
修改使其立即生效
source ~/.zshrc
bash 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置,前面加#就行
vi ~/.bash_profile
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx
修改使其立即生效
source ~/.bash_profile
brew update
原文链接:https://blog.csdn.net/H_WeiC/article/details/107857302
Recommend
-
81
centos默认的源是国外的,访问下载的时候有点慢,用国内的源比较方便需要先把原来的源的配置文件删了rm-fCentOS-Base.repo用如下两个命令下载yum源,只需要用到一个就可以wgethttp://mirrors.163.com/.help/CentOS7-Base-163.repocurl-Ohttp://mirrors.163.com/.he...
-
19
Jitwxs 搜索Mac 安装 brewJitwxs|发表于2020-09-26|更新于2020-12-19|
-
16
将 Google CDN 替换为国内源的 Chrome 扩展,实现网站加速⚡️GitHub 源码地址:https://github.com/justjavac/...。...
-
11
简介 Homebrew 是一款自由及开放源代码的软件包管理系统,用以简化 macOS 和 linux 系统上的软件安装过程。它拥有安装、卸载、更新、查看、搜索等很多实用的功能,通过简单的一条指令,就可以实现包管理,十分方便快捷。 Homebrew
-
11
Install PHP’s imagick extension on Mac with Brew ...
-
6
安装Homebrew不要再改hosts了,直接用这个国内源地址更流畅!
-
6
本文首发于: https://blog.frytea.com/archives/605/ PVE7 安装后默认配置的 apt 软件源和 CT (LXC) 容器模板源均是官方默认的,国内使用性能不佳,建议替换为 清华 Tuna...
-
71
Linux...
-
3
MacOS Monterey 12.3 安装python2.7、php、替换Homebrew为国内源最近走教育优惠 → 2022年苹果教育优惠 Mac全系购买指南渠道 终于把用了5年的17款mac换到二线了,但是迁移到新...
-
19
V2EX › 程序员 PVE8 更改国内源的地址有了吗?
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK