Mac最常用强大的包管理工具,以命令的形式运行于终端,功能就是用于安装软件,最终效果和在网上下载软件包一模一样,只是这个是以命令的方式而已。
用它下载软件或者一些工具包,相对来说更方便而已,毕竟一些开发工具,只提这种下载方式。
安装 Homebrew 时需要使用git,需要用户提前给系统安装 git。
下载指令(直接复制粘贴在终端并回车,十来分钟执行完即可):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
如果下载失败,提示:
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)"
会出现以下提示:
开始执行Brew自动安装程序
[cunkai.wang@foxmail.com]
['2022-12-28 18:19:56']['13.1']
https://zhuanlan.zhihu.com/p/111014448
请选择一个下载brew本体的序号,例如中科大,输入1回车。
源有时候不稳定,如果git克隆报错重新运行脚本选择源。
1、中科大下载源
2、清华大学下载源
3、北京外国语大学下载源
4、腾讯下载源
5、阿里巴巴下载源
请输入序号:
输入序号后回车,期间会需要输入电脑登录密码。
安装完成后,查看安装完成的输出,可能会有一些提示需要执行的指令,按照要求执行后,就可以正常使用了。
使用brew安装其他软件时,可能会出现报错,最后一行是:
Command failed with exit 128: git
此时需要执行:
brew -v
# 打印
Homebrew 3.6.20-261-gb3a71ba
fatal: detected dubious ownership in repository at '/opt/homebrew/Library/Taps/homebrew/homebrew-core'
To add an exception for this directory, call:
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core (no Git repository)
fatal: detected dubious ownership in repository at '/opt/homebrew/Library/Taps/homebrew/homebrew-cask'
To add an exception for this directory, call:
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask (no Git repository)
按照上面的要求,执行它提供的那两条指令后,再安装软件就没问题了:
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