Homebrew安装与使用

960 阅读1分钟

HomebrewmacOS系统上的软件包管理器(也有Linux版本),用于安装、更新、卸载、管理软件包。

安装Homebrew

官方提供的安装方法,在终端中执行命令:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

脚本执行的过程中会提示用户进一步的选项与操作。

查看版本号

$ brew --version
Homebrew 2.1.16
Homebrew/homebrew-core (git revision b1a9; last commit 2019-11-23)
Homebrew/homebrew-cask (git revision a6d16; last commit 2019-11-23)

升级Homebrew

$ brew update

查看已经安装的软件包列表

$ brew list

安装软件包

使用Homebrew安装git

$ brew install git

更新软件包

$ brew upgrade git

或者更新所有软件包:

$ brew upgrade

卸载软件包

$ brew uninstall git

镜像

由于国内恶劣的网络环境,在国内可以使用镜像提供服务。这里介绍清华大学提供的镜像服务。

使用镜像

$ git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

$ brew update

恢复

$ 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

$ brew update

Homebrew

Homebrew 镜像使用帮助

Homebrew-bottles 镜像使用帮助