macOS系统下安装Homebrew

系统版本信息:macOS Mojave 10.14.3

接下来进入正题,最近为了折腾Vue的环境在网上找了很多的资料,包括博客,提问啥的,发现到最后都解决不了问题,一直报错,直到翻到了这个 Mac下使用国内镜像安装HomebrewHomeBrew 官方安装太慢而失败?这么搞就行.(转载),受此启发并结合本身的安装经历,给那篇补充一些细节,并但愿给后来者一些帮助和启发。

这里咱们使用国内镜像安装。在此感谢前面的两位dalaogit

1.获取install文件并编辑

cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
编辑的话直接在Finder里面搜索brew_install,双击以后打开,通常会用Xcode打开。原文说的“ 注释掉BREW_REPO = "https://github.com/Homebrew/brew".freeze和CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze”,不知为什么,我这儿没有 CORE_TAP_REPO这一行,不过不要紧,新增上去就好了。

修改后代码和截图以下github

#!/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere (which is
# unsupported) you can untar https://github.com/Homebrew/brew/tarball/master
# anywhere you like.
HOMEBREW_PREFIX = "/usr/local".freeze
HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze
HOMEBREW_CORE_TAP = "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core".freeze
HOMEBREW_CACHE = "#{ENV["HOME"]}/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 = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze#新增

图片描述

2.开始安装

/usr/bin/ruby ~/brew_install
在这里我没有遇到原文下面提问的朋友遇到的卡住报错不动等问题,仅停顿了一下子。

3.替换源

#替换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

4.brew更新

brew update

最后:ruby

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
相关文章
相关标签/搜索