一个80后
程序员的笔记

安装Homebrew(brew)

官方:http://brew.sh/index_zh-cn.html

安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

如果卡住不走那么就要手工安装了

1、获取install文件

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

2、 打开 brew_install 文件,修改如下:

找到如下代码:

BREW_REPO = “https://github.com/Homebrew/brew“.freeze
CORE_TAP_REPO = “https://github.com/Homebrew/homebrew-core“.freeze

更改为:

BREW_REPO = “https://gitee.com/bbhsky/brew.git “.freeze
CORE_TAP_REPO = “https://gitee.com/bbhsky/homebrew-core.git“.freeze

注意: 新版本HomeBrew可能没有CORE_TAP_REPO这句代码,如果没有不用新增。 如果这个镜像有问题的话,可以换成其他源。

3、执行脚本

/usr/bin/ruby brew_install

如果此时脚本应该停在

==> Tapping homebrew/core

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

出现这个原因是因为源不通,代码来不下来,解决方法就是更换国内镜像源:

手动执行下面这句命令,更换镜像:

git clone https://gitee.com/bbhsky/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

然后把homebrew-core的镜像地址设为中科院的国内镜像

cd "$(brew --repo)"

git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

执行更新,成功:

brew update

最后用这个命令检查无错误:

brew doctor

4、更改默认源

直接使用 Homebrew 还需要更改默认源。以下是将默认源替换为国内 USTC 源的方法。 如下:

替换核心软件仓库

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

替换 cask 软件仓库(提供 macOS 应用和大型二进制文件)

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

替换 Bottles 源(Homebrew 预编译二进制软件包)

bash(默认 shell)用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

zsh 用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

5、brew常用命令

5、brew常用命令
赞(1) 打赏
未经允许不得转载:笨笨天地 » 安装Homebrew(brew)
分享到: 更多 (0)

相关推荐

  • 暂无文章

评论 2

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏