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. 安装Homebrew1 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.gitcd "$(brew --repo homebrew/core) " && git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.gitcd "$(brew --repo homebrew/cask) " && git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-cask.gitbrew update cd "$(brew --repo) " && git remote set-url origin https://github.com/Homebrew/brew.gitcd "$(brew --repo homebrew/core) " && git remote set-url origin https://github.com/Homebrew/homebrew-core.gitcd "$(brew --repo homebrew/cask) " && git remote set-url origin https://github.com/Homebrew/homebrew-cask.gitbrew update
更多内容参考Homebrew/Linuxbrew 镜像使用帮助 。
4. 使用Homebrew4.1. 查找软件4.2. 安装最新版软件4.3. 安装指定版本软件4.4. 安装软件时禁用软件源更新1 HOMEBREW_NO_AUTO_UPDATE=1 brew install mysql
4.5. 升级软件5. 更新Homebrew软件源6. Error opening archive6.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_REMOTEunset HOMEBREW_CORE_GIT_REMOTEunset HOMEBREW_BOTTLE_DOMAIN
7.1. 问题描述使用上面的命令升级sqlite3,出现报错:
1 2 Error: An exception occurred within a child process: FormulaUnavailableError: No available formula with the name "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/sqlite3".
7.2. 解决办法sqlite3对应的软件名是sqlite,因此修改升级命令为:
使用升级后的版本:
1 2 3 4 5 6 sqlite3 --version which sqlite3 cd /usr/local/opt/sqlite/bin && ./sqlite3 --versionecho 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profilesource ~/.bash_profilesqlite3 --version
虽然系统中的sqlite3升级了,但是如果在python中调用sqlite3,还是会调用老版本。 解决办法是重新安装python:
1 2 3 4 5 6 7 pyenv uninstall <your_python_version> PYTHON_CONFIGURE_OPTS="LD_RUN_PATH=/usr/local/opt/sqlite/lib" \ LDFLAGS="-L/usr/local/opt/sqlite/lib -I/usr/local/opt/sqlite/include" \ pyenv install <your_python_version> python -c "import sqlite3; print(sqlite3.sqlite_version)"