根据官网上的方法,在终端输入:html
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
结果仍是被卡在下载阶段,怎么办呢?因而上网搜索到了“Homebrew 的安装方法(官方的方法总是安装失败) 第三方”这篇文章。git
依文中所述,进行安装。因为官方弃用了旧的homebrew仓库,将homebrew程序与软件包拆分红了两个仓库。与文中描述不符,也未能成功安装。因而稍做修改,记录于此。github
新增brew.git与homebrew-core.git镜像ruby
因为官方弃用了旧的homebrew仓库,将homebrew程序与软件包拆分红了两个仓库。为保证用户正常升级,旧镜像将暂时保留一段时间,择期删除。bash
仓库对应关系:curl
github.com/Homebrew/brew -> mirrors.ustc.edu.cn/brew.git
github.com/Homebrew/homebrew-core -> mirrors.ustc.edu.cn/homebrew-core.git
github.com/Homebrew/homebrew(弃用) -> mirrors.ustc.edu.cn/homebrew.gitui
cd ~ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
编辑brew_install文件spa
#!/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".freeze
和CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze
.net
修改成BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
和CORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze
/usr/bin/ruby ~/brew_install
运行修改了的brew_install文件。
替换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 update
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile
做者:采姑娘的小魔钴连接:https://www.jianshu.com/p/6523d3eee50d