一个计算机技术爱好者与学习者

0%

MacOS安装配置Homebrew

1. Homebrew简介

Homebrew: The Missing Package Manager for macOS (or Linux).
Homebrew installs the stuff you need that Apple (or your Linux system) didn’t.

Homebrew是Mac OSX上的软件包管理工具,简称brew。

2. 安装Homebrew

1
2
3
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# 国内安装失败的话,建议换下面的脚本
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

3. 更换Homebrew软件源

1
2
3
4
5
6
7
8
9
cd "$(brew --repo)" && git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo homebrew/core)" && git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git
cd "$(brew --repo homebrew/cask)" && git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-cask.git
brew update
# 还原
cd "$(brew --repo)" && git remote set-url origin https://github.com/Homebrew/brew.git
cd "$(brew --repo homebrew/core)" && git remote set-url origin https://github.com/Homebrew/homebrew-core.git
cd "$(brew --repo homebrew/cask)" && git remote set-url origin https://github.com/Homebrew/homebrew-cask.git
brew update

更多内容参考Homebrew/Linuxbrew 镜像使用帮助

4. 使用Homebrew

4.1. 查找软件

1
brew search mysql

4.2. 安装最新版软件

1
brew install mysql

4.3. 安装指定版本软件

1
brew install mysql@5.7

5. 更新Homebrew软件源

1
brew update-reset

6. Error opening archive

6.1. 问题描述

使用国内brew源出现报错:

1
tar: Error opening archive: Failed to open 'xxx.catalina.bottle.tar.gz'

6.2. 解决办法

暂时改回默认的brew源:

1
2
3
unset HOMEBREW_BREW_GIT_REMOTE
unset HOMEBREW_CORE_GIT_REMOTE
unset HOMEBREW_BOTTLE_DOMAIN