mac OS 安装 homebrew 失败解决方案

1.查看homebrew官网的安装教程,复制安装命令。

 

 

2.打开mac OS终端Terminal,输入安装命令,输入密码,回车确认安装。

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

 

 3.然后你可能会得到一个错误:

fatal: unable to access 'https://github.com/Homebrew/brew/': LibreSSL SSL_read: error:02FFF03C:system library:func(4095):Operation timed out, errno 60
Failed during: git fetch --force origin

也可能是这个错误:

error: RPC failed; curl 28 LibreSSL SSL_read: error:02FFF03C:system library:func(4095):Operation timed out, errno 60
fatal: expected flush after ref listing
Error: Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core failed!
Failed during: /opt/homebrew/bin/brew update --force --quiet

4.出现这个错误是因为墙的原因,解决方案是使用镜像,好用的有清华镜像阿里云镜像,在这里我使用清华的镜像。

5.首先修改homebrew相关的环境变量:

输入命令:

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

然后再运行安装命令:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

安装成功,此时还无法在终端使用brew,需要配置brew的安装路径到环境变量。

 

 6.配置brew的安装路径到环境变量:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

 配置完成即可在终端使用brew命令了,开始愉快的使用吧!

 

posted @ 2022-08-07 07:38  芬尼克斯  阅读(19171)  评论(1编辑  收藏  举报