Mac上Homebrew的使用——Homebrew 使 OS X 更完整
0 Homebrew是啥?
“Homebrew installs the stuff you need that Apple didn’t.——Homebrew 使 OS X 更完整”。
Homebrew的官网[1](多语言版本)简单明了地介绍了如何安装和使用这个工具,并提供了自己的Wiki。
1 安装Homebrew
brew的安装很简单,使用一条ruby命令即可,Mac系统上已经默认安装了ruby。
gerryyang@mba :bin$ruby --version
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/localso 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/localalready. 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 you
 - should 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 :~$brew
 - Example 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-Cookbook
 - Further help:
 - man brew
 - brew home
 - gerryyang@mba :~$
 
3 Homebrew的有趣问题
下面关于Homebrew的一些常见问题[3]:
(1) 在OS X中找不到想要的软件,可以使用brew安装;
- gerryyang@mba :~$brew install wget
 - ==> Downloading http://ftpmirror.gnu.org/wget/wget-1.14.tar.gz
 - ######################################################################## 100.0%
 - ==> ./configure --prefix=/usr/local/Cellar/wget/1.14 --sysconfdir=/usr/local/etc
 - ==> make install
 - Warning: Could not link wget. Unlinking...
 - Error: The `brew link` step did not complete successfully
 - The formula built, but is not symlinked into /usr/local
 - You can try again using `brew link wget'
 - Possible conflicting files are:
 - /usr/local/bin/wget
 - /usr/local/share/man/man1/wget.1
 - ==> Summary
 - <span style="font: 13.0px Monaco">/usr/local/Cellar/wget/1.14: 8 files, 688K, built in 2.3 minutes</span>
 
由于之前使用源码方式安装过wget,因此再用brew安装时会提示冲突的错误,因为/usr/locat/bin/wget已经存在。实际上,Homebrew 将软件包分装到单独的目录(/usr/local/Cellar),然后 symlink 到 /usr/local 中。
(2) 如何更新本地已安装的package呢?
第一步:先更新brew:
brew update
- gerryyang@mba:bin$brew update
 - Already up-to-date.
 
第二步:更新所有package: 
brew upgarde
- gerryyang@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
 - ==> Caveats
 - This formula is keg-only, so it was not symlinked into /usr/local.
 - Mac OS X already provides this software and installing another version in
 - parallel 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 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
 - ==> 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 http://ftpmirror.gnu.org/wget/wget-1.15.tar.gz
 - ######################################################################## 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 install
 - Warning: Could not link wget. Unlinking...
 - Error: The `brew link` step did not complete successfully
 - The formula built, but is not symlinked into /usr/local
 - You 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 seconds
 - gerryyang@mba:bin$
 
(3) 如何删除Homebrew?
If you installed to/usr/localthen you can use the script in thisgist to uninstall — it will onlyremove Homebrew and the stuff Homebrew installed leaving anything elsein/usr/localalone.
Provided you haven’t put anything else in Homebrew’s prefix(brew --prefix), you can generally justrm -rfthat directory. Thisis because Homebrew won’t touch files outside its prefix.
(4) Homebrew下载的package存放的路径在哪里?
- gerryyang@mba:bin$brew --cache
 - /Library/Caches/Homebrew
 - gerryyang@mba:bin$ls /Library/Caches/Homebrew/
 - Formula/ wget-1.14.tar.gz
 - coreutils-8.22.tar.xz wget-1.15.tar.gz
 - openssl-1.0.1f.mavericks.bottle.tar.gz xz-5.0.5.mavericks.bottle.2.tar.gz
 - gerryyang@mba:bin$ls /Library/Caches/Homebrew/Formula/
 - coreutils.brewing openssl.brewing wget.brewing xz.brewing
 - gerryyang@mba:bin$
 
(5) 我可以安装自己的stuff在/usr/local吗?
Yes, brew is designed to not get in your way so you can use it how youlike.
Install your own stuff, but be aware that if you install commonlibraries, like libexpat yourself, it may cause trouble when trying tobuild certain Homebrew formula. As a resultbrew doctorwill warn youabout this.
Thus it’s probably better to install your own stuff to the Cellar andthenbrew linkit. Like so:
$ cd foo-0.1 $ brew diy
./configure —prefix=/usr/local/Cellar/foo/0.1 $ ./configure —prefix=/usr/local/Cellar/foo/0.1 [snip] $ make && make install $ brew link foo
Linking /usr/local/Cellar/foo/0.1… 17 symlinks created
在我的环境上检测是这样的:
- gerryyang@mba:bin$brew doctor
 - Warning: Unbrewed dylibs were found in /usr/local/lib.
 - If you didn't put them there on purpose they could cause problems when
 - building Homebrew formulae, and may need to be deleted.
 - Unexpected dylibs:
 - /usr/local/lib/libboost_atomic.dylib
 - /usr/local/lib/libboost_chrono.dylib
 - /usr/local/lib/libboost_context.dylib
 - /usr/local/lib/libboost_date_time.dylib
 - /usr/local/lib/libboost_filesystem.dylib
 - /usr/local/lib/libboost_graph.dylib
 - /usr/local/lib/libboost_iostreams.dylib
 - /usr/local/lib/libboost_locale.dylib
 - /usr/local/lib/libboost_log.dylib
 - /usr/local/lib/libboost_math_c99.dylib
 - /usr/local/lib/libboost_math_c99f.dylib
 - /usr/local/lib/libboost_math_c99l.dylib
 - /usr/local/lib/libboost_math_tr1.dylib
 - /usr/local/lib/libboost_math_tr1f.dylib
 - /usr/local/lib/libboost_math_tr1l.dylib
 - /usr/local/lib/libboost_prg_exec_monitor.dylib
 - /usr/local/lib/libboost_program_options.dylib
 - /usr/local/lib/libboost_python.dylib
 - /usr/local/lib/libboost_random.dylib
 - /usr/local/lib/libboost_regex.dylib
 - /usr/local/lib/libboost_serialization.dylib
 - /usr/local/lib/libboost_signals.dylib
 - /usr/local/lib/libboost_system.dylib
 - /usr/local/lib/libboost_thread.dylib
 - /usr/local/lib/libboost_timer.dylib
 - /usr/local/lib/libboost_unit_test_framework.dylib
 - /usr/local/lib/libboost_wave.dylib
 - /usr/local/lib/libboost_wserialization.dylib
 - Warning: Unbrewed static libraries were found in /usr/local/lib.
 - If you didn't put them there on purpose they could cause problems when
 - building Homebrew formulae, and may need to be deleted.
 - Unexpected static libraries:
 - /usr/local/lib/libboost_atomic.a
 - /usr/local/lib/libboost_chrono.a
 - /usr/local/lib/libboost_context.a
 - /usr/local/lib/libboost_coroutine.a
 - /usr/local/lib/libboost_date_time.a
 - /usr/local/lib/libboost_exception.a
 - /usr/local/lib/libboost_filesystem.a
 - /usr/local/lib/libboost_graph.a
 - /usr/local/lib/libboost_iostreams.a
 - /usr/local/lib/libboost_locale.a
 - /usr/local/lib/libboost_log.a
 - /usr/local/lib/libboost_math_c99.a
 - /usr/local/lib/libboost_math_c99f.a
 - /usr/local/lib/libboost_math_c99l.a
 - /usr/local/lib/libboost_math_tr1.a
 - /usr/local/lib/libboost_math_tr1f.a
 - /usr/local/lib/libboost_math_tr1l.a
 - /usr/local/lib/libboost_prg_exec_monitor.a
 - /usr/local/lib/libboost_program_options.a
 - /usr/local/lib/libboost_python.a
 - /usr/local/lib/libboost_random.a
 - /usr/local/lib/libboost_regex.a
 - /usr/local/lib/libboost_serialization.a
 - /usr/local/lib/libboost_signals.a
 - /usr/local/lib/libboost_system.a
 - /usr/local/lib/libboost_test_exec_monitor.a
 - /usr/local/lib/libboost_thread.a
 - /usr/local/lib/libboost_timer.a
 - /usr/local/lib/libboost_unit_test_framework.a
 - /usr/local/lib/libboost_wave.a
 - /usr/local/lib/libboost_wserialization.a
 - Warning: You have unlinked kegs in your Cellar
 - Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
 - those kegs to fail to run properly once built. Run `brew link` on these:
 - wget
 - gerryyang@mba:bin$
 
(6) 为什么选择Homebrew这个名字?
mxcl was too concerned with the beer theme and didn’t consider that the project may actually prove popular. By the time he realized it was too late. However, today, the first google hit for “homebrew” is not beer related ;-)
(7) 关于更多地QA可以参考Homebrew的Wiki[4]
(8) 一些常用安装推荐
- gerryyang@mba:bin$brew list
 - coreutils openssl wget xz
 
Introduction to Coreutils
The GNU Core Utilities are the basic file, shell and text manipulationutilities of the GNU operating system.
These are the core utilitieswhich are expected to exist on every operating system.
http://www.gnu.org/software/coreutils/
4 参考
[1] http://brew.sh/index_zh-cn.html
[2] https://github.com/Homebrew/homebrew/wiki/Installation
[3] https://github.com/Homebrew/homebrew/wiki/FAQ
[4] https://github.com/Homebrew/homebrew/wiki
Mac上Homebrew的使用——Homebrew 使 OS X 更完整的更多相关文章
- Mac上Homebrew的使用 (Homebrew 使 OS X 更完整)
		
0 Homebrew是啥? “Homebrew installs the stuff you need that Apple didn’t.——Homebrew 使 OS X 更完整”. Homebr ...
 - 我在 Mac 上都用什么
		
我在 Mac 上都用什么 Homebrew Homebrew 是统一管理 macOS 中应用的最佳方法之一,而且大量优秀的应用都可以在 Homebrew 中找到. 就不做过多介绍了, 有兴趣可以看相关 ...
 - Mac上的包管理器Homebrew的介绍及安装和使用实践
		
Homebrew的作用 Homebrew是OS X上强大的包管理器,为系统软件提供了非常方便的安装方式,独特式的解决了包的依赖问题,并不再需要烦人的sudo,一键式编译,无参数困扰. 如何安装Home ...
 - mac上安装homebrew
		
1:关于homebrew下载地址 homebrew下载地址网上版本很多:我用了几个都是显示 404 bad request 如图:均无法现在 有一个网址会给出最新的 安装地址: the URL is: ...
 - 【mac】mac上使用brew 安装速度慢/每次使用brew 都会卡在updating homebrew不动/更换homebrew的镜像源
		
有没有出现一下这样的情况: 如果有,请继续往下走 1.打开mac的命令窗口,键入如下命令 cd /usr/local/Homebrew 2.更换homebrew的默认源[更换为中科大的镜像源] git ...
 - MAC上有哪些优秀的日常软件| 入门级Mac OS 用户必备软件
		
本文整理的网友反馈的MAC上有哪些优秀的日常软件+入门级Mac OS 用户必备软件,感兴趣的朋友可以看看,下载下来试用一样便知实不实用.如有更好的推荐,欢迎留言. MAC上有哪些优秀的日常软件 Tim ...
 - 记一次在mac上源码编译curl,使其支持NSS的过程
		
一.背景 在一次学习https原理的过程中,希望客户端指定特定的cipher suites来抓包分析SSL/TLS的握手过程,就想到了使用curl工具,而不是使用浏览器. 接下来使用man curl找 ...
 - Mac下软件包管理器-homebrew
		
类似于redhat系统的yum,ubuntu的apt-get,mac系统下也有相应的包管理容器:homebrew.用法与apt-get.yum大同小异,都是对安装软件做一些安装删除类的命令行操作,以下 ...
 - Mac上VMWare Fusion配置多台cent os
		
一.创建虚拟机(准备工作) 1.使用VMWare Fusion 创建第一台虚拟机 2.选择操作系统(本次使用的是使用cent os 6.5 64bit 系统) 3.选择磁盘大小(楼主mac上的磁盘大小 ...
 
随机推荐
- HDU 4348 To the moon(可持久化线段树)
			
To the moon Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tota ...
 - 查看执行计划plustrace:set autotrace trace exp stat(SP2-0618、SP2-0611)
			
执行计划是SQL获取和处理数据的途径和方法. 执行计划和性能 SQL -- 数据库性能的始作俑者 所有的数据库性能,几乎全部来自SQL. 优秀的SQL是数据库最大的福祉. 一条很烂的SQL,可以搞瘫一 ...
 - Writing a Discard Server 写个抛弃服务器   世上最简单的协议
			
Netty.docs: User guide for 4.x https://netty.io/wiki/user-guide-for-4.x.html The most simplistic pro ...
 - Macbook pro 13" Installs Ubuntu 18.04
			
最新版的 MacBook对Ubuntu的支持(或者反过来?)不是很好,但是除了Suspend和resume功能没找到方法使用外,其他都还好,可用. 1.mac在OSX中先安装refind引导,如果开启 ...
 - ISO C++标准委员会不是一个一般意义上权力机构,基本上愿意交会费,愿意自己出时间,出酒店机票,出提案,就可以申请加入。
			
ISO C++标准委员会不是一个一般意义上权力机构,基本上愿意交会费,愿意自己出时间,出酒店机票,出提案,每年全世界参加会议被专家巨细靡遗地评头论足,就可以申请加入. 所以参加标准委员会背景各异,有人 ...
 - 3类数据库的联动:mysql、mongodb、redis
			
3类数据库的联动:mysql.mongodb.redis from pymysql import * from pymongo import * from redis import * class M ...
 - 你知道军装照H5浏览了多少次吗? 10亿
			
7月29日,由人民日报客户端推出的<快看呐!这是我的军装照>(以下简称<军装照>)H5页面,由它所引发的全民晒“军装照”现象级事件,据统计,截至8月18日,<军装照> ...
 - OCR技术浅探 : 文字定位和文本切割(2)
			
文字定位 经过前面的特征提取,我们已经较好地提取了图像的文本特征,下面进行文字定位. 主要过程分两步: 1.邻近搜索,目的是圈出单行文字: 2.文本切割,目的是将单行文本切割为单字. 邻近搜索 我们可 ...
 - nginx的相关信息
			
Nginx安装 nginx官网:https://nginx.org/ 安装准备:nginx依赖pcre库,要先安装pcre(nginx在rewrite时需要解析正则,PCRE是正则解析库) yum i ...
 - vs git 推送远程会失败.
			
Gitblit使用admin创建版本库. 使用VS无法推送到远程服务器. VS 2017 Git failed with a fatal error 可能是帐号不应不上. 本地上帐号与服务器的 ...