MacOS系统终端使用brew下载程序过慢的问题

290人次看过本文

homebrew

MacOS系统终端利用brew安装或者升级程序下载过慢时,比如安装升级ffmpeg,那是因为homebrew镜像在国外,国内访问可能不顺畅,所以建议把homebrew镜像换成国内阿里云的镜像,那样就能达到下载加速的效果。
原先我们执行brew命令安装的时候,跟下面3个仓库地址有关:
brew.git
homebrew-core.git
homebrew-bottles

把上面三个仓库源地址全部替换成国内Aliyun提供的源地址即可。

操作步骤
1,替换/还原brew.git仓库地址
(替换成阿里巴巴的 brew.git 仓库地址,终端执行以下代码)
cd “$(brew –repo)”
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

(还原为官方提供的 brew.git 仓库地址,终端执行以下代码)
cd “$(brew –repo)”
git remote set-url origin https://github.com/Homebrew/brew.git

2,替换/还原homebrew-core.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

(还原为官方提供的 homebrew-core.git 仓库地址,终端执行以下代码)
cd “$(brew –repo)/Library/Taps/homebrew/homebrew-core”
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

3,替换/还原homebrew-bottles
这个步骤跟你的MacOs系统使用的shell版本有关系,首先查看shell版本,查看shell版本方法,终端执行:
echo $SHELL
如果输出结果是 /bin/zsh,则参考zsh 终端操作方式替换/还原homebrew-bottles
如果输出结果是 /bin/bash,则参考bash 终端操作方式替换/还原homebrew-bottles

【zsh终端操作方式】
替换成aliyun的 homebrew-bottles 访问地址:
echo ‘export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles’ >> ~/.zshrc
source ~/.zshrc

还原为官方提供的 homebrew-bottles 访问地址
vi ~/.zshrc
# 然后,删除 HOMEBRED_BOTTLE_DOMAIN 这一行配置
source ~/.zshrc

【bash终端操作方式】
替换成aliyun的 homebrew-bottles 访问地址:
echo ‘export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles’ >> ~/.bash_profile
source ~/.bash_profile

还原为官方提供的 homebrew-bottles 访问地址
vi ~/.bash_profile
# 然后,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置
source ~/.bash_profile

终端执行完以上三个步骤重启终端即刻生效。

如何安装ffmpeg
终端执行
brew install ffmpeg
查看ffmpeg信息
终端执行
brew info ffmpeg
更新升级ffmpeg
更新所有包,终端执行
brew update
单独更新升级ffmpeg,终端执行
brew upgrade ffmpeg

转载或复制本文请附带:素材地带
本文URL: https://www.chanbee.com/774.html
本文素材:CHANBEE-774.rar
本站素材解压密码是:chanbee.com

(⚠️注:本站的素材绝大数是以医学、科学和健康这几方面为主,主要适合学医人员用来学习交流,非学医人员建议不要浏览。)

素材地带微信公众号

上一篇

解决Vmware虚拟机USB图标灰色识别不了设备方法

下一篇

MacOS使用ffmpeg批量转换视频格式

随机推荐

近期文章

相关推荐