mac big sur版本安装brew及替换国内镜像

1、下载脚本

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

如果无法访问,修改host,添加以下内容

199.232.68.133 raw.githubusercontent.com

修改brew_install源git仓库

#BREW_REPO = “https://github.com/Homebrew/brew”
BREW_REPO = “git://mirrors.ustc.edu.cn/brew.git”

执行命令进行安装

sh brew_install
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
==> The following new directories will be created:
/opt/homebrew/bin
/opt/homebrew/etc
/opt/homebrew/include
/opt/homebrew/lib
/opt/homebrew/sbin
/opt/homebrew/share
/opt/homebrew/var
/opt/homebrew/opt
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/var/homebrew
/opt/homebrew/var/homebrew/linked
/opt/homebrew/Cellar
/opt/homebrew/Caskroom
/opt/homebrew/Frameworks

Press RETURN to continue or any other key to abort

2、解决安装core/cask失败

==> Tapping homebrew/core
Cloning into ‘/opt/homebrew/Library/Taps/homebrew/homebrew-core’…
fatal: unable to access ‘https://github.com/Homebrew/homebrew-core/’: LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
Error: Failure while executing; git clone https://github.com/Homebrew/homebrew-core /opt/homebrew/Library/Taps/homebrew/homebrew-core exited with 128.
Error: Failure while executing; /opt/homebrew/bin/brew tap homebrew/core exited with 1.
Failed during: /opt/homebrew/bin/brew update --force

Control+C 中断安装

cd /opt/homebrew/Library/Taps
mkdir homebrew #如果存在此文件夹就跳过这一步
cd homebrew
git clone https://mirrors.ustc.edu.cn/homebrew-core.git
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git

完成安装

cd ~
sh brew_install
➜ ~ sh brew_install
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /usr/sbin/chown yuanjian:admin /opt/homebrew
==> Downloading and installing Homebrew…
HEAD is now at 4a90a5a5d Merge pull request #10199 from reitermarkus/check-https-content
Already up-to-date.
Warning: /opt/homebrew/bin is not in your PATH.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations

==> Next steps:

  • Run brew help to get started
  • Further documentation:
    https://docs.brew.sh
    ➜ ~ brew --version

3、添加到path

brew --version
zsh: command not found: brew #如果可以显示出版本号则跳过此节
vi ~/.zshrc

敲击I键,添加以下内容后,ESC键,后输入 “:wq”保存

export PATH=$PATH:/opt/homebrew/bin

source ~/.zshrc
brew --version
Homebrew 2.7.1

4、替换为国内源

替换核心软件仓库

cd “$(brew --repo)”
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git

替换core源

cd “$(brew --repo)/Library/Taps/homebrew/homebrew-core”
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git

替换cask源

cd “$(brew --repo)/Library/Taps/homebrew/homebrew-cask”
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

替换Bottles源

echo ‘export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles’ >> ~/.zshrc
source ~/.zshrc

5、检查

brew update

Already up-to-date.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值