macOS 安装 Homebrew 教程:多种方式与国内镜像加速
创作时间:
作者:
@小白创作中心
macOS 安装 Homebrew 教程:多种方式与国内镜像加速
引用
CSDN
1.
https://m.blog.csdn.net/weixin_44297859/article/details/144886758
Homebrew是macOS上最受欢迎的包管理工具,它让你能够便捷地安装、更新和管理各种软件包。本文将介绍多种安装方式,并提供国内镜像加速方案。
一、什么是 Homebrew?
Homebrew 是 macOS 上最受欢迎的包管理工具,它让你能够便捷地安装、更新和管理各种软件包。
二、安装前准备
- 确保系统要求:
- macOS Monterey (12.0) 或更高版本
- 已安装 Command Line Tools (CLT)
- 安装 Command Line Tools:
xcode-select --install
三、安装方式
1. 国内镜像安装(推荐)
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
2. 官方安装脚本
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
3. Git 克隆安装
sudo git clone https://github.com/Homebrew/brew /opt/homebrew
四、配置国内镜像源
1. 中科大镜像
# 替换 brew.git
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 替换 homebrew-core.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 替换 homebrew-cask.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
2. 清华大学镜像
# 替换 brew.git
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替换 homebrew-core.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 替换 homebrew-cask.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
五、验证安装
# 查看 Homebrew 版本
brew --version
# 检查 Homebrew 状态
brew doctor
六、常见问题解决
- 权限问题
sudo chown -R $(whoami) $(brew --prefix)/*
- 更新 Homebrew
brew update
- 重置镜像源(恢复官方源)
# 重置 brew.git
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
# 重置 homebrew-core.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
# 重置 homebrew-cask.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
七、总结
本文介绍了在 macOS 上安装 Homebrew 的多种方式,并提供了国内镜像加速方案。建议国内用户使用镜像安装和配置镜像源,可以显著提升下载速度。如果遇到问题,可以参考常见问题解决方案或查看官方文档。
参考资料
- 中科大镜像站
- 清华大学镜像站
- Gitee 镜像
热门推荐
PSpice软件交流扫描分析入门教程
马斯克是如何做时间管理的?
中国女足十大名将:从传奇球星到现役球员的风采
拒绝HR话术不想面试
九锡之礼:古代王权象征与法律地位的深远影响
《凡人歌》:以温暖底色绘就人间真实
葡萄酒的结冰点:酒精、糖分与温度的奇妙关系
如何提高动力电池量产阶段激光焊接的一次合格率和稳定性
孙思邈留下的千古名方,用来治腰突,很有用
头发毛孔堵塞了怎么办
遇到拆迁如何找到好律师
房屋被拆前后,应如何正确收集有关证据?
从草图到3D效果图:设计思维与实践
经济情况与股票:如何利用经济指标判断股票走势
婴儿发热正常吗?一文读懂发热原因与应对方法
夏季养肝,喝3茶、揉2穴,帮你清热解毒、疏肝解郁!
俾斯麦级战列舰:二战时期的海上霸主
如何编写完美的测试需求文档模板?
购房的个人所得税如何计算?
申请城市低保需要什么条件和手续
农村供水信息化管理系统解决方案
“2分钟时代”,加电像加油一样快?新能源汽车换电模式调查
中国传统文化中的四大核心思想
上海社区健身房最低1块钱包天!分时段按次结费和买月卡,谁更划算?
嵌入式AI是如何实现的,需要哪些技术栈
机器学习算法评价指标详解:从回归到分类
艾略特波浪理论在商品期货市场中的应用
哪些动物处于食物链的顶端?揭秘自然界的顶级掠食者
旭旭宝宝怎么火起来的,旭旭宝宝爆火揭秘:直播达人崛起之路
亚硝酸钠的作用与用途有哪些