mac book上修复安装brew

背景

mac book 升级操作系统以后,brew变得缺胳膊少腿,不能正常运行了
搜了很多修复的办法都不能工作。

初次尝试

后面去brew官网https://brew.sh/找到这个命令

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

但是因为有那一堵伟大的墙,很多资源拉不下来。

开动脑筋

机制的我想,国内肯定有人碰到类似的问题,然后已经有墙内办法了,于是在gitee上搜索试试运气,运气不错,找到这个项目
https://gitee.com/cunkai/HomebrewCN
里面的下面这条命令帮我解决了问题

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

小试牛刀

$ brew install watchman
....此处省略日志若干行

$ which watchman
/usr/local/bin/watchman

完美解决,一劳永逸

为了一劳永逸解决问题,把brew源切换为国内源吧,我是切换到清华大学的仓库,操作如下

# 替换各个源
$ git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 刷新源
$ brew update

具体参照 Mac 下 brew 切换为国内源

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容