mac下更换镜像安装Homebrew教程
文章目录
Homebrew是一款包管理工具,目前支持macOS和linux系统。主要有四个部分组成: brew、homebrew-core 、homebrew-cask、homebrew-bottles。
Homebrew官方默认安装脚本:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
如果你等待一段时间之后遇到下面提示,就说明无法访问官方脚本地址:
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation timed out
请按照下面 「安装说明」中步骤执行。
安装说明
1, 安装homebrew-core 和 homebrew-cask:
创建并进入安装目录:
cd /usr/local/mkdir -p Homebrew/Library/Taps && cd Homebrew/Library/Taps
分别安装中科大镜像源的homebrew-core 和 homebrew-cask:
HOMEBREW_CORE_GIT_REMOTE=https://mirrors.ustc.edu.cn/homebrew-core.gitgit clone git://mirrors.ustc.edu.cn/homebrew-core.git-
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
2, 安装homebrew:
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
最后看到==> Installation successful!就说明安装成功了。
最最后更新下:
brew update
补充
1, 参考文档
2, 如何卸载Homebrew
使用官方脚本同样会遇到uninstall地址无法访问问题,可以使用下面脚本:
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall.sh)"
3, 设置镜像
brew、homebrew/core是必备项目,homebrew/cask、homebrew/bottles按需设置。通过 brew config 命令可以查看相关配置信息。
3.1 中科大源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.gitgit -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.gitgit -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.gitbrew update
3.2 清华大学源
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.gitgit -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.gitgit -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.gitbrew update
3.3 恢复默认源
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.gitgit -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.gitgit -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.gitbrew update
整理不易,觉得有帮助的话还望点个赞
———By 🧑🏻💻 × Fluox
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论