一、Homebrew介绍
Homebrew是Unix平台(MacOS、Linux)下一款软件工具包,通过terminal命令就可以实现安装、卸载、更新、查看、搜索应用等功能。
二、国内大神脚本安装Homebrew
只需要一行命令,安装速度很快,没有网络问题,中文日志,强烈推荐:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
附上大神的地址:zhuanlan.zhihu.com/p/111014448
三、官方脚本安装Homebrew
打开Homebrew项目开源地址:github.com/Homebrew/br… ,点击右侧 brew.sh,如图:
复制下图中的命令:
在terminal中执行刚才复制的命令:
如果在执行命令中,遇到报错,参考本篇文章第四部分,解决相关报错。
在经历漫长的等待后,最终Homebrew安装成功。
四、安装Homebrew时报错
报错一:在terminal执行命令时,报URL443错误:
fatal: unable to access 'https://github.com/Homebrew/brew/': LibreSSL SSL_connect: Operation timed out in connection to github.com:443
解决办法:
找到网址对应的IPv4地址,配置到系统hosts文件。具体步骤如下:
- 复制URL域名:
https://github.com
- 打开IP查询网站:www.ipaddress.com/ ,输入复制的URL域名,点击回车键查询
- 打开系统hosts文件
打开访达文件夹-->然后按command+shift+g-->然后输入/etc/hosts-->回车
- 使用文本编译器打开hosts文件,追加进去查询到的IP和URL,并保存文件:
- terminal执行ping url命令,发现可以访问URL了
继续执行安装Homebrew命令,发现可以执行成功了。
报错二:Failed during: git fetch --force origin
fatal: the remote end hung up unexpectedly0.54 MiB | 33.00 KiB/s
fatal: early EOF
fatal: index-pack failed
Failed during: git fetch --force origin
解决办法:
这是git clone报的错,拉取的是外网的数据,网络速度过低或者拉取时间过长,我们git config修改一下:
git config --global http.lowSpeedLimit 0
#单位/秒
git config --global http.lowSpeedTime 999999