HomeBrew全新安装搜索不到库

1. 安装

  • 互联网用户复制这段到终端运行即可安装:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • 对于局域网用户,首先 macOS 默认情况下终端是不走代理的,所以挂了梯子也不行,需要先对终端配置代理,参考SimonLiu009老师的文字,其实就是在~/.zshrc(根据所用终端不同)文件下增加这行代码,添加完会在新开终端中生效,没有这个文件可以直接新建一个。
      1. 仅设置http和https代理(只对当前终端有效)
    export http_proxy=http://proxyAddress:port export https_proxy=http://proxyAddress:port

      1. 仅设置socks5代理(只对当前终端有效,代理地址假设为socks5://127.0.0.1:1080)
    export ALL_PROXY=socks5://127.0.0.1:1080

      1. 长期设置需要将上述命令加入bash profile
      1. 通过alias来快速切换
    alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080" alias unsetproxy="unset ALL_PROXY" alias ip="curl -i http://ip.cn"

2. 配置正确的库 这时候安装一些不常见的库会出现No formulae found in taps.的报错
运行 brew doctor 发现默认安装的homebrew-coregit 地址不对
Warning: Suspicious https://github.com/Homebrew/homebrew-core git origin remote found. The current git origin is: https://github.com/Homebrew/brewWith a non-standard origin, Homebrew won't update properly. You can solve this by setting the origin remote: git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" remote set-url origin https://github.com/Homebrew/homebrew-core

【HomeBrew全新安装搜索不到库】按照提示输入上述命令,结果
Error: Fetching /usr/local/Homebrew failed! /usr/local/Homebrew/Library/Homebrew/brew.sh: line 109: /usr/local/bin/brew: No such file or directory

发现 brew 命令不起作用了
下面尝试进入文件夹,强行更新homebrew-core文件夹
cd /usr/local/Homebrew/Library/Taps/homebrew/ rm -rf homebrew-core git clone https://github.com/Homebrew/homebrew-core.git

brew 命令还是不行,一番查找发现是整个bin文件夹都没有了,一般来说这是启动文件所在的文件夹,安装的时候会释放,于是想到重装。
重新执行/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)",文件校验通过,没有重新下载,很快提示安装完成。
尝试brew doctor 显示Your system is ready to brew.
完成。

    推荐阅读