homebrew安装过程中从github拉取仓库超时的问题解决办法

最近github上的仓库拉不下来,在mac上面安装homebrew时,也无法将安装所需的仓库拉下来。困扰了很久,找到了两种解决办法。

让git走代理

git config --global http.proxy socks5://127.0.0.1:1086
git config --global https.proxy socks5://127.0.0.1:1086

拉取https的仓库url时,速度提升并不明显,可能时代理慢了,然后就没尝试让git协议的也走代理了。

修改安装脚本

homebrew的安装命令官方给出的是:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)",其实就是从github上面下载一个脚本,然后用ruby去执行它。所以将该ruby脚本下载下来,然后再将其中的仓库名称修改成国内的镜像仓库,可明显提高速度。

这里下载下来的脚本改名为了brew_install

修改brew_install中BREW_REPO配置项为:BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze,保存,直接用ruby运行:/usr/bin/ruby brew_install

后面的安装过程中,home-core和home-cask的仓库又变成了从github上面拉,可能是brew_install里面还有配置没改到,但是没找到该配置,并且找到了另外一种方法:直接将home-core的仓库拉下来,放到相应的位置,home-cask亦是如此即可。

git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
git clone git://mirrors.ustc.edu.cn/homebrew-cask.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask --depth=1

至此基本完工。

发布了166 篇原创文章 · 获赞 118 · 访问量 26万+

猜你喜欢

转载自blog.csdn.net/asahinokawa/article/details/102693131
今日推荐