记录Mac安装homebrew的各种坑 报错 zsh: command not found / no Ruby script found in input

2022-09-03 11:26:39

记录一次Mac安装homebrew的各种坑

刚Mac对macos完全是小白状态,按照现有网上的做法已经进行不下去,查了很多资料结合起来,终于装好了,希望能帮到大家

不用镜像装的时候,虽然报已经安装成功,但是终端仍然报

zsh: command not found

后面跟跟着教程各种配 .bash_profile .zshec 文件还是没用,
所以只能尝试一下通过镜像安装,按照其他教程的办法,卡在了执行 brew_install 脚本,终端报错

/usr/bin/ruby: no Ruby script found in input (LoadError)

后来受另一篇文章的启发,找到了问题所在,下面进入正题。

正文

  1. 获取brew_install文件到本地( homebrew地址已更新,官网可查)
    这里踩了n次坑
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install
  1. 下载之后,用文本打开,在33行将原本的注释,换成国内镜像
    这里踩了n+1次坑
BREW_REPO="https://github.com/Homebrew/brew"

注释,换成

BREW_REPO="git://mirrors.ustc.edu.cn/brew.git"
  1. 更改 brew_install 权限
chmod 755 brew_install
  1. 运行脚本
./brew_insatll

这里会报错 BREW_REPO not found
更换到中科院的镜像:

git clone git://mirrors.ustc.edu.cn/homebrew-core.git//usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

再次运行脚本 ./brew_insatll
或者直接找到该文件用终端打开,大功告成。。。

结论:太年轻。。。遇到时间就百度,一开始就走偏了,越走越远,其实应该多多思考~
参考文章:
[ https://www.cnblogs.com/ianlab/p/12296768.html]

[https://blog.csdn.net/qq_33591200/article/details/82882562?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task]

  • 作者:Seven.28
  • 原文链接:https://blog.csdn.net/seven_28/article/details/104934623
    更新时间:2022-09-03 11:26:39