homebrew安装
ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
解决brew安装速度慢的问题(替换homebrew镜像源)
1.替换brew.git:
<span class="hljs-built_in">cd</span> <span class="hljs-string"><span class="hljs-variable">$(brew --repo)</span>
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
</span>
2.替换homebrew-core.git:
<span class="hljs-built_in">cd</span> <span class="hljs-string"><span class="hljs-variable">$(brew --repo)</span>/Library/Taps/homebrew/homebrew-core</span>
git remote <span class="hljs-built_in">set</span>-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
3.终端输入命令:
echo $SHELL 看输出结果是/bin/zsh还是/bin/bash
- /bin/zsh替换homebrew-bottles:
<span class="hljs-built_in">echo</span> <span class="hljs-string">'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles'</span> >> ~/.zshrc
<span class="hljs-built_in">source</span> ~/.zshrc
- /bin/bash替换homebrew-bottles:
<span class="hljs-built_in">echo</span> <span class="hljs-string">'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'</span> >> ~/.bash_profile
<span class="hljs-built_in">source</span> ~/.bash_profile
4.恢复homebrew国内镜像源配置
- 重置brew.git
<span class="hljs-built_in">cd</span> <span class="hljs-string"><span class="hljs-variable">$(brew --repo)</span></span>
git remote <span class="hljs-built_in">set</span>-url origin https://github.com/Homebrew/brew.git
- 重置homebrew-core.git
<span class="hljs-built_in">cd</span> <span class="hljs-string"><span class="hljs-variable">$(brew --repo)</span>/Library/Taps/homebrew/homebrew-core</span>
git remote <span class="hljs-built_in">set</span>-url origin https://github.com/Homebrew/homebrew-core.git
- 重置homebrew-bottles
将刚添加到~/.bash_profile文件的语句注释掉即可
解决brew安装包一直卡在Updating Homebrew
运行命令brew install node,结果界面一直卡在Updating Homebrew上,有两种解决办法
方法一:关闭brew每次执行命令时的自动更新(推荐)
vim ~/.bash_profile
<span class="hljs-comment"># 新增一行</span>
<span class="hljs-built_in">export</span> HOMEBREW_NO_AUTO_UPDATE=<span class="hljs-literal">true</span>
方法二(懒人方法):
出现Updating Homebrew的时候ctrl+c一下就行