文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
1. 简介
Homebrew是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件,相当于linux下的apt-get、yum;Homebre可以在Mac上安装一些OS X没有的UNIX工具,Homebrew安装工具的目录为/usr/local/Cellar,并在/usr/local/bin中创建了工具对应的符号链接。例如Homebrew安装的cmake:
代码语言:javascript复制# lrwxr-xr-x中的l表示link(链接),->表示链接的文件
$ ls -l /usr/local/bin/cmake
lrwxr-xr-x 1 *** *** 31 12 1 09:23 /usr/local/bin/cmake -> ../Cellar/cmake/3.7.0/bin/cmake
2. 安装
Home是通过Ruby安装的,而Mac上默认安装了Ruby。Homebrew的安装命令为:
代码语言:javascript复制ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
3. Homebrew用法
- 安装软件
# 命令形式: brew install software-name
# 安装wget
$ brew install wget
==> Installing dependencies for wget: openssl
==> Installing wget dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2j.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2j.el_capitan.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
==> Summary
�� /usr/local/Cellar/openssl/1.0.2j: 1,695 files, 12M
==> Installing wget
==> Downloading https://homebrew.bintray.com/bottles/wget-1.18.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring wget-1.18.el_capitan.bottle.tar.gz
�� /usr/local/Cellar/wget/1.18: 9 files, 1.6M
- 卸载软件
# 命令形式: brew uninstall software-name
# 卸载wget
$ brew uninstall wget
Uninstalling /usr/local/Cellar/wget/1.18... (9 files, 1.6M)
- 查看安装的软件
# 命令形式: brew list
$ brew list
cmake maven node openssl pkg-config wget xz
- 查看哪些软件需要更新
# 命令形式:brew outdated
$ brew outdated
node (6.5.0) < 7.2.0
pkg-config (0.29.1_1) < 0.29.1_2
- 更新Homebrew
# 命令形式:brew update
$ brew update
Already up-to-date.
- 显示brew信息
# 命令形式:brew info
$ brew info
7 kegs, 7,868 files, 95.5M
- 软件升级
# 命令形式:brew upgrade software-name
$ brew upgrade pkg-config
==> Upgrading 1 outdated package, with result:
pkg-config 0.29.1_2
==> Upgrading pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1_2.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.29.1_2.el_capitan.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pkg-config
Target /usr/local/bin/pkg-config
is a symlink belonging to pkg-config. You can unlink it:
brew unlink pkg-config
To force the link and overwrite all conflicting files:
brew link --overwrite pkg-config
To list all files that would be deleted:
brew link --overwrite --dry-run pkg-config
Possible conflicting files are:
/usr/local/bin/pkg-config -> /usr/local/Cellar/pkg-config/0.29.1_1/bin/pkg-config
/usr/local/share/aclocal/pkg.m4 -> /usr/local/Cellar/pkg-config/0.29.1_1/share/aclocal/pkg.m4
/usr/local/share/doc/pkg-config/pkg-config-guide.html
/usr/local/share/doc/pkg-config/pkg-config-guide.html
/usr/local/share/man/man1/pkg-config.1 -> /usr/local/Cellar/pkg-config/0.29.1_1/share/man/man1/pkg-config.1
==> Summary
�� /usr/local/Cellar/pkg-config/0.29.1_2: 10 files, 627.4K
$ brew link --overwrite pkg-config
- 搜索软件
# 命令形式:brew search software-name
$ brew search wget
wget ✔ wgetpaste