一、Homebrew是什么?
homebrew是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等功能。通过简单的指令可以实现包管理,而不用关心各种依赖和文件路径情况。
二、检查是否已安装
brew -v
未安装:
展示 zsh:command not found:brew
已安装:
三、安装方法
方法一:官方链接
Homebrew官网:http://brew.sh/
安装Homebrew的命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
国内网络大概率会下载失败。一般报错
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
方法二:使用国内源
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
选择任意一个下载源(有概率失败,我使用中科大源安装成功了)
如果安装失败了,要先进行卸载,才能重新安装
卸载指令:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
使用brew安装git时遇到问题:
fatal: not in a git directory Error: Command failed with exit 128: git
解决方法:
brew -v查看会有两个提示,提示用户设置homebrew-cask和homebrew-core的文件路径为safe.directory,即使用如下命名:
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
然后再进行安装即可