Mac国内镜像源安装homebrew(排雷)


获取install文件并编辑

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

编辑brew_install文件

#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby # This script installs to /usr/local only. To install elsewhere you can just # untar https://github.com/Homebrew/brew/tarball/master anywhere you like or # change the value of HOMEBREW_PREFIX. HOMEBREW_PREFIX = "/usr/local".freeze HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze HOMEBREW_CACHE = "#{ENV["HOME"]}/Library/Caches/Homebrew".freeze HOMEBREW_OLD_CACHE = "/Library/Caches/Homebrew".freeze #BREW_REPO = "https://github.com/Homebrew/brew".freeze BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze #CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze CORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze 

注释掉BREW_REPO = "https://github.com/Homebrew/brew".freezeCORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze

修改为BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freezeCORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze

安装

/usr/bin/ruby ~/brew_install 

运行修改了的brew_install文件。

替换homebrew源

替换homebrew默认源

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

替换homebrew-core源

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

brew更新

brew update

设置 bintray镜像

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile
 
 
作者:采姑娘的小魔钴
链接:https://www.jianshu.com/p/6523d3eee50d


主要是排雷,如上方法在安装时会得到如下错误:

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...

fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 

Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

Error: Failure while executing: /usr/local/bin/brew tap homebrew/core

Failed during: /usr/local/bin/brew update --force

这个错误的原因还不知道是为什么(上面明明已经改了源的),在这里研究了一下,可以试着打开https://

mirrors.ustc.edu.cn/brew.git ,看到地址其实是好的,那么就是git 的clone 失败了,那解决办法就是我们自己clone一下

1.首先进入下载了一半的brew目录

cd "$(brew --repo)"
2.进入准备下载homebrew-core的目录
cd Library/Taps/
在这里建立两层目录

mkdir homebrew

cd homebrew/

mkdir homebrew-core

3.进入目录

cd homebrew-core/

4.开始clone

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

一会就下载完了。brew就可以用了。 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM