github怎么切换到gitee_MAC安装Homebrew总是失败怎么办?

Homebrew是一款包管理工具,目前支持macOS和Linux,只要有四部分组成:brew、homebrew-core、homebrew-cask、homebrew-bottles。

名称说明
brewHomebrew源代码仓库
homebrew-coreHomebrew核心源
homebrew-cask提供macOS应用和大型二进制文件的安装
homebrew-bottles预编译二进制软件包

安装教程

Homebrew默认安装脚本:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

这里使用的是GitHub仓库,因为网络原因,所以这个官方命令很大可能是失败的。很快就能看到下面的提示信息

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

这时候建议切换国内脚本地址。

# 安装脚本
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

# 卸载脚本
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

常见问题

  1. 修改国内镜像源

# 查看已经配置的镜像源地址
brew config
# 输出结果如下所示,Core那行后main有镜像源地址,比如下面使用的是中科大镜像源
calos@calosdeiMac ~ % brew config
HOMEBREW_VERSION: 2.5.11-45-g8d9a767-dirty
ORIGIN: https://mirrors.ustc.edu.cn/brew.git
HEAD: 8d9a767e6de653332433e542bdfc1da8ab428acc
Last commit: 73 minutes ago
Core tap ORIGIN: https://mirrors.ustc.edu.cn/homebrew-core.git
Core tap HEAD: 280430beab8f35e4a5a6001e4b0744df34d9d149
Core tap last commit: 2 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 12
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: dodeca-core 64-bit dunno
Clang: 12.0 build 1200
Git: 2.24.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.0.1-x86_64
CLT: N/A
Xcode: 12.2

# 替换镜像源操作
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
brew update
# 长期替换homebrew-bottles
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
  1. 安装过程中可能还会出现下载cask和cask-versions的情况过,下载地址为Github,下载过程极其缓慢,可能会出现失败的情况,如下所示:

calos@calosdeiMac ~ % brew cask install homebrew/cask-versions/java8

==> Tapping homebrew/cask-versions
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions'...
remote: Enumerating objects: 230502, done.
^Cceiving objects:  20% (48247/230502), 9.57 MiB | 16.00 KiB/s   

这时候我们可以尝试更换镜像源解决问题,使用国内的下载地址,手动把文件下载到相应的文件夹。

安装homebrew-cask

git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask

安装homebrew-cask-versions

git clone https://gitee.com/excelsi0r/homebrew-cask-versions.git  /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions

这两个git clone如果能够正常执行完毕的话,就可以说brew cask命令已经可以正常识别了。

参考链接

  1. https://www.cnblogs.com/xibushijie/p/13335988.html

  2. https://newsn.net/say/brew-cask-command.html

  3. https://zhuanlan.zhihu.com/p/111014448

公众号提供的所有的资源都是免费提供的如果你觉得有帮助的话,不如……

文末点个赞走一波,十分感谢

9a152da8d48918c58a79f44002b31ed4.png

回复” 加群 “获取小编微信,加好友交朋友。我们有微信编程交流群,欢迎各位
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值