Homebrew-brew-macOS包管理工具

简介

macOS的包管理工具
主页:https://brew.sh/index_zh-cn

安装

1
2
3
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 同时在终端显示安装日志并且将安装日志保存在文件中
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | tee ~/Desktop/Homebrew安装日志.log

=> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
get_owner:1: command not found: stat -f
get_group:1: command not found: stat -f
get_owner:1: command not found: stat -f
get_group:1: command not found: stat -f
get_owner:1: command not found: stat -f
get_group:1: command not found: stat -f
get_owner:1: command not found: stat -f
get_group:1: command not found: stat -f
==> The following existing directories will be made group writable:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man8
==> The following existing directories will have their owner set to username:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man8
==> The following existing directories will have their group set to admin:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man8
==> The following new directories will be created:
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/sbin
/usr/local/var
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew
/usr/local/var/homebrew/linked
/usr/local/Cellar
/usr/local/Caskroom
/usr/local/Homebrew
/usr/local/Frameworks

更新&升级

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 列出安装的包
brew list
# 更新Homebrew本身, formulae索引等, 需要先安装git
brew update
# 安装应用, 例如wget, 安装到/usr/local/Cellar/wget, ln到/usr/local/bin目录下
brew install wget
# 安装带UI app, 插件, 字体(fonts)及其他非开源应用
brew cask install firefox
# 更新app
brew upgrade git
# 诊断依赖冲突等
brew doctor
# 搜索app
brew search xxx
# 卸载xxx.app
brew uninstall xxx

其它命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 查看配置
brew config
# 打开包主页
brew home git
# 查看包信息
brew ino git
# 查看包依赖
brew deps wget #结果显示gettext libidn2 libunistring openssl
# 清理旧版本
brew cleanup git
brew cleanup
# 显示可更新的包列表
brew outdated
# 再来个卸载
brew rm wget # uninstall wget
brew remove -h

其它

HomeBrew环境变量

https://docs.brew.sh/Manpage#environment

HomeBrew与Python

Python has been installed as
/usr/local/bin/python3

Unversioned symlinks python, python-config, pip etc. pointing to
python3, python3-config, pip3 etc., respectively, have been installed into
/usr/local/opt/python@3.9/libexec/bin

You can install Python packages with
pip3 install
They will install into the site-package directory
/usr/local/lib/python3.9/site-packages

tkinter is no longer included with this formula, but it is available separately:
brew install python-tk@3.9

See: https://docs.brew.sh/Homebrew-and-Python

为 homeBrew 设置代理

homebrew不使用代理的问题

查看 homebrew 默认安装的组件版本

以python为例,brew install使用的配置文件在这里
https://github.com/Homebrew/homebrew-core/blob/master/Aliases/python


Homebrew-brew-macOS包管理工具
https://dnacore.github.io/post/919ead87-d2b2-4b2f-ac93-a34349365362.html
作者
DNACore
发布于
2019年4月15日
更新于
2023年7月14日
许可协议