一 简介:
homebrew 就是macOS(或 Linux)缺失的软件包的管理器。
二 安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
三 卸载
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
四 更新自己
brew update
五 常用操作
5.1 安装其他
brew install watchman
5.2 卸载其他
brew uninstall watchman
5.3 更新其他
brew upgrade watchman
5.4 查看已安装
brew list
六 其他问题
6.1 下载 homebrew 太慢、链接不稳定、报错:curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused)
(1)将脚本下载到本地,修改链接地址,再运行脚本。
将脚本下载到本地,文件示例
cd Desktop/
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brewinstall
打开文件 brewinstall,替换里面BREW_REPO地址:
目前有两个,选一个即可:
#清华大学地址
BREW_REPO="https://mirrors.ustc.edu.cn/brew.git"
#阿里云地址
BREW_REPO="https://mirrors.aliyun.com/homebrew/brew.git"
保存文件,终端运行。
/bin/bash brewinstall
(2)脚本运行过程中会卡在Cloning into ‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core’…这步,这个时候我们可以强制结束脚本然后手动处理。
mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/
cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://mirrors.ustc.edu.cn/homebrew-core.git
(3)至此 brew 已经下载完成。更改 homebrew 、homebrew-core 和homebrew-bottles的镜像地址。
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
在bash_profile 里添加
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
(4)关闭brew每次执行命令时的自动更新。
在bash_profile添加
export HOMEBREW_NO_AUTO_UPDATE=true
(5) 恢复
删除bash_profile里的相关内容
cd $(brew --repo)
git remote set-url origin https://github.com/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/homebrew-core.git
七 参考
https://brew.sh/index_zh-cn
https://docs.brew.sh/FAQ#how-do-i-uninstall-homebrew
https://docs.brew.sh/Manpage
http://www.ilianliankan.com/blogs/8
https://blog.csdn.net/DiyHzp/article/details/90763558
https://www.cnblogs.com/trotl/p/11862796.html