美文网首页
2020-05-13 MacOS下安装homebrew

2020-05-13 MacOS下安装homebrew

作者: 臭臭猫爱不爱吃鱼 | 来源:发表于2020-05-13 22:27 被阅读0次

因为国内网络不给力,用homebrew上提供的指令,中途会连接失败报错。搜了一些可以用国内镜像文件,但是网上解决方法都是比较老的homebrew安装指令,但是思路是一样的
-Homebrew官网上最新的为sh文件

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

-然后尝试使用命令

curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install.sh

-修改brew_install.sh中定义仓库的这一行

BREW_REPO="https://mirrors.ustc.edu.cn/brew"

-执行

sudo ./brew_install.sh

后又报command not found.

-执行chmod u+x *.sh再次执行sh文件,这次没有command找不到,但是报语法错误了。。
-换种执行方式,在Terminal执行 /bin/bash brew_install.sh 这次没有语法错误了,但是又报新的错,镜像仓库没有找到
-根据报错内容替换镜像仓库url

BREW_REPO="git://mirrors.ustc.edu.cn/brew.git"

-进展喜人,但目前在Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...这一行又卡了,又在网上搜索,果断关闭当前命令程序

  • 手动从中科院镜像下载上一步卡住的core
git clone [git://mirrors.ustc.edu.cn/homebrew-core.git/](git://mirrors.ustc.edu.cn/homebrew-core.git/) /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

替换core仓库

cd "$(brew --repo)"

git remote set-url origin [https://mirrors.ustc.edu.cn/brew.git](https://mirrors.ustc.edu.cn/brew.git)

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin [https://mirrors.ustc.edu.cn/homebrew-core.git](https://mirrors.ustc.edu.cn/homebrew-core.git)

-替换核心软件仓库

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin [https://mirrors.ustc.edu.cn/homebrew-core.git](https://mirrors.ustc.edu.cn/homebrew-core.git)

替换 cask 软件仓库(提供 macOS 应用和大型二进制文件)

cd "$(brew --repo)"/Library/Taps/caskroom/homebrew-cask
git remote set-url origin [https://mirrors.ustc.edu.cn/homebrew-cask.git](https://mirrors.ustc.edu.cn/homebrew-cask.git)

如果cask没有安装过,执行上一步会提示找不到目录,尝试手动下载cask:

git clone [https://mirrors.ustc.edu.cn/homebrew-cask.git/](https://mirrors.ustc.edu.cn/homebrew-cask.git/) /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask --depth=1

替换 Bottles 源(Homebrew 预编译二进制软件包)

bash(默认 shell)用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=[https://mirrors.ustc.edu.cn/homebrew-bottles'](https://mirrors.ustc.edu.cn/homebrew-bottles') >> ~/.bash_profile
source ~/.bash_profile

最后成功,可以愉快的装软件了。
最后几步参考这个 https://www.jianshu.com/p/1911a9b3f506

辛辛苦苦把homebrew安装上了,结果现在可能ios更新了,又用不了了,D'oh!

相关文章

网友评论

      本文标题:2020-05-13 MacOS下安装homebrew

      本文链接:https://www.haomeiwen.com/subject/iplanhtx.html