折腾了好久,执行
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
开始一直报错Failed to connect to raw.githubusercontent.com port 443: Connection refused error: Error: 7,
尝试过改动git config
的代理,没有用,换中科大的源,也没有用,最后解决办法如下,重装command line tools
,再执行安装指令,homebrew
安装成功。
removing the old tools
$ rm -rf /Library/Developer/CommandLineTools
install xcode command line tools again
$ xcode-select --install
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Mac下使用国内镜像安装Homebrew
MBP上的brew很老了,就想把brew更新一下,顺便安装一下NodeJs。无奈更新的过程一直卡在网络下载,毫不动弹。想想,应该是Repo访问不到的原因,于是重装brew。
根据官网上的方法,在终端输入:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
结果还是被卡在下载阶段,怎么办呢?于是上网搜索到了[“Homebrew 的安装方法(官方的方法老是安装失败) 第三方”]https://my.oschina.net/shede333/blog/364468这篇文章。
依文中所述,进行安装。由于官方弃用了旧的homebrew仓库,将homebrew程序与软件包拆分成了两个仓库。与文中描述不符,也未能成功安装。于是稍作修改,记录于此。
国内的镜像
新增brew.git与homebrew-core.git镜像。由于官方弃用了旧的homebrew仓库,将homebrew程序与软件包拆分成了两个仓库。为保证用户正常升级,旧镜像将暂时保留一段时间,择期删除。
仓库对应关系:
- 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.git
[引自:新增brew.git与homebrew-core.git镜像]https://servers.ustclug.org/2016/04/add-brew-and-homebrew-core-mirror/
安装
获取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".freeze
和CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze
修改为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源
替换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
本文由 创作,采用 知识共享署名4.0 国际许可协议进行许可。本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为: 2020/05/16 13:35