Homebrew安装、卸载、可能的报错及解决方案_Mac

上一篇安装node,brew install node,问题又来了,-bash: brew: command not found,突然想起来,前两天把homebrew卸载了,翻翻笔记,2018年11月28日???,好记性不如烂笔头这句话真的要掂量掂量了,烂笔头太久了也是会腐烂消失的,不好,不好。。。

1、安装

brew.sh/index_zh-cn


/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2、可能的报错及解决方案:

我为什么知道这么多,因为每次安装或者换电脑总会出各种错,所以我笔记里有各种各样的报错,当然也是附带解决方法的,毕竟程序员的思维,出了问题肯定要解决的,不可能留着它过年过节啥的???。

(1)、Warning: /usr/local/bin is not in your PATH.


解决方法:

终端输入:sudo vim .bash_profile

键盘i,在最后面添加一句

export PATH=/usr/local/bin:$PATH

然后esc退出insert状态,并在最下方输入:wq保存退出

(2)、

fatal: unable to access 'https://github.com/Homebrew/brew/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:50517 
Failed during: git fetch origin master:refs/remotes/origin/master --tags —force

解决方法1:

  1. ping github.com 获取ip地址
  2. Command+Shift+G,打开/etc/hosts文件,将域名添加上就可以了:192.30.253.113 github.comhosts文件修改后,会提示没有权限,分享一个我的做法:将hosts文件复制一个到桌面,添加完域名,保存,再将此文件拖回到etc文件夹下,替换掉原来的文件,中间根据提示输入用户密码即可


解决方法2:

  • 查询下是否设置了代理:
git config --global http.proxy
  • 上述命令之后,如果运行有结果输出,那就是设置了代理,通过下个命令取消设置:
git config --global --unset http.proxy

再查询,就没了,然后再安装,就能成功了!

(3)、chown: /usr/local: Operation not permitted

解决方法:

先卸载:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

重新安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3、升级:

brew update

4、卸载:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

编辑于 2020-04-18 18:13