看完就会的 Homebrew 安装教程

6,299 阅读1分钟

Homebrew是mac下的包管理工具。安装和卸载都可以通过命令直接操作。安装的应用会放在 /use/local 目录下,方便管理。

官网地址

安装命令

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

问题1

Failed to connect to raw.githubusercontent.com port 443: Connection refused

这可能是 DNS 的问题,可以设置以下 DNS

DNS:
谷歌:8.8.8.8
阿里:223.5.5.5 或 223.6.6.6

问题2: homebrew-core 和 home-cask 下载很慢

会卡在脚本这行很久:

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

解决:手动下载 core 和 cask

homebrew-core:

//下载 
git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

homebrew-task:

//下载 
git clone git://mirrors.ustc.edu.cn/homebrew-cask.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask --depth=1

更换修改镜像源

如果经历过问题2的,只需要更换 brew 的镜像源

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

brew 更新

brew update

安装历史版本,使用 Cask Versions

git clone git://mirrors.ustc.edu.cn/homebrew-cask-versions/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions --depth=1

brew 安装 java8 失败

具体的可以看:mac使用brew安装Java8

我的sdk版本:8u261

文件链接 密码: a9bh

参考链接

Mac HomeBrew国内镜像安装方法

西北农林科技大学镜像管理