标签:git -- repo Mac https homebrew brew Homebrew 安装
官方
Homebrew是Mac上非常优秀的软件包管理工具。
前提
Mac安装Homebrew的前提条件:
- 64bit Intel CPU或Apple Silicon CPU(M1)
- macOS Mojave(10.14)或更高版本
- 安装Xcode命令行工具(Command Line Tools for Xcode)
- 可以通过命令行xcode-select --install安装
- shell(比如bash或zsh)
安装
打开终端,输入以下命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
其他安装方法
由于国内的网络环境等问题,使用官方的安装方法可能无法安装成功。可以尝试使用其他更适合国内网络环境的安装方法,参考地址:https://brew.idayer.com/。
安装homebrew-core
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
安装homebrew-cask
cd "$(brew --repo)/Library/Taps/homebrew/"
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
源
为了加速以后使用Homebrew安装其他软件的过程,建议设置软件源为国内源。
查看源
cd "$(brew --repo)" && git remote -v
cd "$(brew --repo homebrew/core)" && git remote -v
cd "$(brew --repo homebrew/cask)" && git remote -v
设置源
设置为中科大的源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
brew update
设置bottles镜像
从macOS Catalina(10.15.x) 版开始,Mac使用zsh作为默认shell,使用的配置文件:.zprofile
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zprofile
source ~/.zprofile
如果是以前的macOS版本,Mac使用bash作为默认shell,使用的配置文件:.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
重置为官方源
可以通过以下命令还原回官方源。
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
# zsh 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置
vi ~/.zprofile
# export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
source ~/.zprofile
# bash 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置
vi ~/.bash_profile
# export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
source ~/.bash_profile
brew update
卸载
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall)"
标签:git,--,repo,Mac,https,homebrew,brew,Homebrew,安装 来源: https://www.cnblogs.com/mjios/p/14497925.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。