Mac上Homebrew的使用 (Homebrew 使 OS X 更完整)

2014-02-22 wcdj

0 Homebrew是啥?

“Homebrew installs the stuff you need that Apple didn’t.——Homebrew 使 OS X 更完整”。

Homebrew的官网[1](多语言版本)简单明了地介绍了如何安装和使用这个工具,并提供了自己的Wiki。

1 安装Homebrew

brew的安装很简单,使用一条ruby命令即可,Mac系统上已经默认安装了ruby。ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]关于安装brew的详细说明可以参考其github上的wiki说明[2]:

"Installation

The suggested and easiest way to install Homebrew is on the homepage. We don’t duplicate it here because it is asecurity risk to list it on a user-editable wiki.

The standard script installs Homebrew to /usr/local so that you don’t need sudo when youbrew install. It is acareful script, it can be run even if you have stuff installed to/usr/local already. It tells you exactly what it will do before itdoes it too. And you have to confirm everything it will do before itstarts.

There are other ways to install Homebrew which provide you with moreflexibility. They are listed below the requirements.

"gerryyang@mba:~$ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"It appears Homebrew is already installed. If your intent is to reinstall youshould do the following before running this installer again:rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup

由于我的系统上已经安装过brew,,因此再次执行安装命令会提示我brew已经存在。

2 Homebrew的用法

查看brew的具体用法:

gerryyang@mba:~$brewExample usage: brew [info | home | options ] [FORMULA…] brew install FORMULA… brew uninstall FORMULA… brew search [foo] brew list [FORMULA…] brew update brew upgrade [FORMULA…] brew pin/unpin [FORMULA…]Troubleshooting: brew doctor brew install -vd FORMULA brew [–env | –config]Brewing: brew create [URL [–no-fetch]] brew edit [FORMULA…] open https://github.com/Homebrew/homebrew/wiki/Formula-CookbookFurther help: man brew brew homegerryyang@mba:~$

3 Homebrew的有趣问题

下面关于Homebrew的一些常见问题[3]:

(1) 在OS X中找不到想要的软件,可以使用brew安装;

gerryyang@mba:~$brew install wget==> Downloading ######################################################################## 100.0%==> ./configure –prefix=/usr/local/Cellar/wget/1.14 –sysconfdir=/usr/local/etc==> make installWarning: Could not link wget. Unlinking…Error: The `brew link` step did not complete successfullyThe formula built, but is not symlinked into /usr/localYou can try again using `brew link wget’Possible conflicting files are:/usr/local/bin/wget/usr/local/share/man/man1/wget.1==> Summary/usr/local/Cellar/wget/1.14: 8 files, 688K, built in 2.3 minutes

),然后 symlink 到 /usr/local 中。(2) 如何更新本地已安装的package呢?第一步:先更新brew:

brew update

gerryyang@mba:bin$brew updateAlready up-to-date.第二步:更新所有package:brew upgardegerryyang@mba:bin$brew upgrade==> Upgrading 1 outdated package, with result:wget 1.15==> Upgrading wget==> Installing wget dependency: openssl==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/openssl-1.0######################################################################## 100.0%==> Pouring openssl-1.0.1f.mavericks.bottle.tar.gz==> CaveatsThis formula is keg-only, so it was not symlinked into /usr/local.Mac OS X already provides this software and installing another version inparallel can cause all kinds of trouble.The OpenSSL provided by OS X is too old for some software.Generally there are no consequences of this for you. If you build yourown software and it requires this formula, you’ll need to add to yourbuild variables:LDFLAGS: -L/usr/local/opt/openssl/libCPPFLAGS: -I/usr/local/opt/openssl/include==> security find-certificate -a -p /Library/Keychains/System.keychain > ‘/usr/l==> security find-certificate -a -p /System/Library/Keychains/SystemRootCertific==> mv -f /usr/local/etc/openssl/osx_cert.pem.tmp /usr/local/etc/openssl/osx_cer==> Summary/usr/local/Cellar/openssl/1.0.1f: 429 files, 15M==> Installing wget==> Downloading ######################################################################## 100.0%==> ./configure –prefix=/usr/local/Cellar/wget/1.15 –sysconfdir=/usr/local/etc –with-ssl=openssl –with-libssl-prefix=/usr/local/opt/openssl –disable-iri==> make installWarning: Could not link wget. Unlinking…Error: The `brew link` step did not complete successfullyThe formula built, but is not symlinked into /usr/localYou can try again using `brew link wget’Possible conflicting files are:/usr/local/bin/wget/usr/local/share/man/man1/wget.1==> Summary/usr/local/Cellar/wget/1.15: 8 files, 700K, built in 73 secondsgerryyang@mba:bin$

(3) 如何删除Homebrew?

If you installed to /usr/local then you can use the script in thisgist to uninstall — it will onlyremove Homebrew and the stuff Homebrew installed leaving anything elsein/usr/local alone.

怕走崎岖路,莫想登高峰。

Mac上Homebrew的使用 (Homebrew 使 OS X 更完整)

相关文章:

你感兴趣的文章:

标签云: