Homebrew
安装配置
可以安装官网方式进行安装,不过国内安装多数情况下都会安装失败
解决方案:更换镜像安装
安装
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
配置
# 对于 bash 用户:
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
参考:https://brew.idayer.com/guide/change-source/
切换镜像源
查看镜像源:
git -C "$(brew --repo)" remote get-url origin
git -C "$(brew --repo homebrew/core)" remote get-url origin
git -C "$(brew --repo homebrew/cask)" remote get-url origin
修改镜像源:
# 修改配置
git -C "$(brew --repo)" remote set-url origin 'https://github.com/Homebrew/brew.git'
git -C "$(brew --repo homebrew/core)" remote set-url origin 'https://github.com/Homebrew/homebrew-core.git'
git -C "$(brew --repo homebrew/cask)" remote set-url origin 'https://github.com/Homebrew/homebrew-cask.git'
# 替换后更新
brew update
# 替换 Homebrew-bottles
# 对于 bash 用户:
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
- 官方:
https://github.com/Homebrew/
- 中科大:
https://mirrors.ustc.edu.cn/
- 清华:
https://mirrors.tuna.tsinghua.edu.cn/
关闭自动更新
# 临时关闭
$ export HOMEBREW_NO_AUTO_UPDATE=true
# 永久关闭
$ vim ~/.zshrc
# 添加配置
export HOMEBREW_NO_AUTO_UPDATE=true
# 生效
$ source ~/.zshrc
常用指令
# 查看帮助
$ brew --help
# 安装
$ brew install xxx
# 卸载
$ brew uninstall xxx
# 查找已安装软件列表
$ brew list
# 查看软件安装目录
$ brew list xxx
FQA
安装软件报错
Warning: formula.jws.json: update failed, falling back to cached version.
解决方法:
$ export HOMEBREW_NO_INSTALL_FROM_API=1