安装homebrew 你可能会遇到的各种问题

533 阅读1分钟

1.执行 

/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

这个报错大概的意思就是你的电脑被拒绝访问 raw.githubusercontent.com

我是这样解决的

2.打开网站: [https://www.ipaddress.com/](https://www.ipaddress.com/) 查询一下 raw.githubusercontent.com对应的IP 地址

然后将对应的IP地址写入你的hosts文件

如果编辑hosts文件你又遇到了麻烦,请按照以下步骤来执行。

3.终端输入sudo vi /etc/hosts,输入密码后打开hosts文件

键盘按i(插入),编辑完之后按esc(退出编辑)

再按 'shift' + ':' 键

输入wq(保存并退出)

到此,就修改好了hosts文件

4.再在终端输入

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

就可以继续进行安装了,这时候还有一个需要注意的是,执行代码之后会弹出一句话意思是按return键继续进行安装,不能按其他键,按其他键会终止!!

然后等待安装直到看到installation successful才算安装完成。

问题又来了,我并没有看到successful****哈哈**,而是在tapping的时候又报错了**

没办法只能用镜像了,而官网提供的阿里镜像按照步骤也还是遇到了问题

在执行上面代码的时候又报错了

cd: no such file or directory: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

5.继续解决报错

1)进入到taps文件夹 然后创建homebrew文件

cd /usr/local/Homebrew/Library/Taps

mkdir homebrew

cd homebrew

执行命令

git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

2)替换homebrew源

替换homebrew默认源

cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

替换homebrew-core默认源

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

 应用生效

brew update

到此brewhome就安装完成了!!!

个人觉得要安装react-native需要的各种还是用vpn好点