0%

MacOS安装配置Homebrew

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。

安装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)"

更换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 镜像使用帮助

使用Homebrew

查找软件

1
brew search mysql

安装最新版软件

1
brew install mysql

安装指定版本软件

1
brew install mysql@5.7

更新Homebrew软件源

1
brew update-reset

Error opening archive

问题描述

使用国内brew源出现报错:

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

解决办法

暂时改回默认的brew源:

1
2
3
unset HOMEBREW_BREW_GIT_REMOTE
unset HOMEBREW_CORE_GIT_REMOTE
unset HOMEBREW_BOTTLE_DOMAIN
  • 本文作者: 好好学习的郝
  • 本文链接: https://www.voidking.com/dev-macos-homebrew/
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!源站会及时更新知识点及修正错误,阅读体验也更好。欢迎分享,欢迎收藏~