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.

"

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

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

2 Homebrew的用法

查看brew的具体用法:

  1. gerryyang@mba :~$brew
  2. Example usage:
  3. brew [info | home | options ] [FORMULA...]
  4. brew install FORMULA...
  5. brew uninstall FORMULA...
  6. brew search [foo]
  7. brew list [FORMULA...]
  8. brew update
  9. brew upgrade [FORMULA...]
  10. brew pin/unpin [FORMULA...]
  11. Troubleshooting:
  12. brew doctor
  13. brew install -vd FORMULA
  14. brew [--env | --config]
  15. Brewing:
  16. brew create [URL [--no-fetch]]
  17. brew edit [FORMULA...]
  18. open https://github.com/Homebrew/homebrew/wiki/Formula-Cookbook
  19. Further help:
  20. man brew
  21. brew home
  22. gerryyang@mba :~$

3 Homebrew的有趣问题

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

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

  1. gerryyang@mba :~$brew install wget
  2. ==> Downloading http://ftpmirror.gnu.org/wget/wget-1.14.tar.gz
  3. ######################################################################## 100.0%
  4. ==> ./configure --prefix=/usr/local/Cellar/wget/1.14 --sysconfdir=/usr/local/etc
  5. ==> make install
  6. Warning: Could not link wget. Unlinking...
  7. Error: The `brew link` step did not complete successfully
  8. The formula built, but is not symlinked into /usr/local
  9. You can try again using `brew link wget'
  10. Possible conflicting files are:
  11. /usr/local/bin/wget
  12. /usr/local/share/man/man1/wget.1
  13. ==> Summary
  14. <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

  1. gerryyang@mba:bin$brew update
  2. Already up-to-date.

第二步:更新所有package: 
brew upgarde

  1. gerryyang@mba:bin$brew upgrade
  2. ==> Upgrading 1 outdated package, with result:
  3. wget 1.15
  4. ==> Upgrading wget
  5. ==> Installing wget dependency: openssl
  6. ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/openssl-1.0
  7. ######################################################################## 100.0%
  8. ==> Pouring openssl-1.0.1f.mavericks.bottle.tar.gz
  9. ==> Caveats
  10. This formula is keg-only, so it was not symlinked into /usr/local.
  11. Mac OS X already provides this software and installing another version in
  12. parallel can cause all kinds of trouble.
  13. The OpenSSL provided by OS X is too old for some software.
  14. Generally there are no consequences of this for you. If you build your
  15. own software and it requires this formula, you'll need to add to your
  16. build variables:
  17. LDFLAGS:  -L/usr/local/opt/openssl/lib
  18. CPPFLAGS: -I/usr/local/opt/openssl/include
  19. ==> security find-certificate -a -p /Library/Keychains/System.keychain > '/usr/l
  20. ==> security find-certificate -a -p /System/Library/Keychains/SystemRootCertific
  21. ==> mv -f /usr/local/etc/openssl/osx_cert.pem.tmp /usr/local/etc/openssl/osx_cer
  22. ==> Summary
  23. /usr/local/Cellar/openssl/1.0.1f: 429 files, 15M
  24. ==> Installing wget
  25. ==> Downloading http://ftpmirror.gnu.org/wget/wget-1.15.tar.gz
  26. ######################################################################## 100.0%
  27. ==> ./configure --prefix=/usr/local/Cellar/wget/1.15 --sysconfdir=/usr/local/etc --with-ssl=openssl --with-libssl-prefix=/usr/local/opt/openssl --disable-iri
  28. ==> make install
  29. Warning: Could not link wget. Unlinking...
  30. Error: The `brew link` step did not complete successfully
  31. The formula built, but is not symlinked into /usr/local
  32. You can try again using `brew link wget'
  33. Possible conflicting files are:
  34. /usr/local/bin/wget
  35. /usr/local/share/man/man1/wget.1
  36. ==> Summary
  37. /usr/local/Cellar/wget/1.15: 8 files, 700K, built in 73 seconds
  38. 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存放的路径在哪里?

  1. gerryyang@mba:bin$brew --cache
  2. /Library/Caches/Homebrew
  3. gerryyang@mba:bin$ls /Library/Caches/Homebrew/
  4. Formula/                                wget-1.14.tar.gz
  5. coreutils-8.22.tar.xz                  wget-1.15.tar.gz
  6. openssl-1.0.1f.mavericks.bottle.tar.gz  xz-5.0.5.mavericks.bottle.2.tar.gz
  7. gerryyang@mba:bin$ls /Library/Caches/Homebrew/Formula/
  8. coreutils.brewing  openssl.brewing  wget.brewing  xz.brewing
  9. 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

在我的环境上检测是这样的:

  1. gerryyang@mba:bin$brew doctor
  2. Warning: Unbrewed dylibs were found in /usr/local/lib.
  3. If you didn't put them there on purpose they could cause problems when
  4. building Homebrew formulae, and may need to be deleted.
  5. Unexpected dylibs:
  6. /usr/local/lib/libboost_atomic.dylib
  7. /usr/local/lib/libboost_chrono.dylib
  8. /usr/local/lib/libboost_context.dylib
  9. /usr/local/lib/libboost_date_time.dylib
  10. /usr/local/lib/libboost_filesystem.dylib
  11. /usr/local/lib/libboost_graph.dylib
  12. /usr/local/lib/libboost_iostreams.dylib
  13. /usr/local/lib/libboost_locale.dylib
  14. /usr/local/lib/libboost_log.dylib
  15. /usr/local/lib/libboost_math_c99.dylib
  16. /usr/local/lib/libboost_math_c99f.dylib
  17. /usr/local/lib/libboost_math_c99l.dylib
  18. /usr/local/lib/libboost_math_tr1.dylib
  19. /usr/local/lib/libboost_math_tr1f.dylib
  20. /usr/local/lib/libboost_math_tr1l.dylib
  21. /usr/local/lib/libboost_prg_exec_monitor.dylib
  22. /usr/local/lib/libboost_program_options.dylib
  23. /usr/local/lib/libboost_python.dylib
  24. /usr/local/lib/libboost_random.dylib
  25. /usr/local/lib/libboost_regex.dylib
  26. /usr/local/lib/libboost_serialization.dylib
  27. /usr/local/lib/libboost_signals.dylib
  28. /usr/local/lib/libboost_system.dylib
  29. /usr/local/lib/libboost_thread.dylib
  30. /usr/local/lib/libboost_timer.dylib
  31. /usr/local/lib/libboost_unit_test_framework.dylib
  32. /usr/local/lib/libboost_wave.dylib
  33. /usr/local/lib/libboost_wserialization.dylib
  34. Warning: Unbrewed static libraries were found in /usr/local/lib.
  35. If you didn't put them there on purpose they could cause problems when
  36. building Homebrew formulae, and may need to be deleted.
  37. Unexpected static libraries:
  38. /usr/local/lib/libboost_atomic.a
  39. /usr/local/lib/libboost_chrono.a
  40. /usr/local/lib/libboost_context.a
  41. /usr/local/lib/libboost_coroutine.a
  42. /usr/local/lib/libboost_date_time.a
  43. /usr/local/lib/libboost_exception.a
  44. /usr/local/lib/libboost_filesystem.a
  45. /usr/local/lib/libboost_graph.a
  46. /usr/local/lib/libboost_iostreams.a
  47. /usr/local/lib/libboost_locale.a
  48. /usr/local/lib/libboost_log.a
  49. /usr/local/lib/libboost_math_c99.a
  50. /usr/local/lib/libboost_math_c99f.a
  51. /usr/local/lib/libboost_math_c99l.a
  52. /usr/local/lib/libboost_math_tr1.a
  53. /usr/local/lib/libboost_math_tr1f.a
  54. /usr/local/lib/libboost_math_tr1l.a
  55. /usr/local/lib/libboost_prg_exec_monitor.a
  56. /usr/local/lib/libboost_program_options.a
  57. /usr/local/lib/libboost_python.a
  58. /usr/local/lib/libboost_random.a
  59. /usr/local/lib/libboost_regex.a
  60. /usr/local/lib/libboost_serialization.a
  61. /usr/local/lib/libboost_signals.a
  62. /usr/local/lib/libboost_system.a
  63. /usr/local/lib/libboost_test_exec_monitor.a
  64. /usr/local/lib/libboost_thread.a
  65. /usr/local/lib/libboost_timer.a
  66. /usr/local/lib/libboost_unit_test_framework.a
  67. /usr/local/lib/libboost_wave.a
  68. /usr/local/lib/libboost_wserialization.a
  69. Warning: You have unlinked kegs in your Cellar
  70. Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
  71. those kegs to fail to run properly once built. Run `brew link` on these:
  72. wget
  73. 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) 一些常用安装推荐

  1. gerryyang@mba:bin$brew list
  2. 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的使用相关推荐

  1. Mac上Homebrew安装应用非常慢、切换Homebrew源

    Homebrew时mac上非常好用的一个包管理工具,但由于网络环境原因,可能在使用Homebrew安装应用的时候会非常慢,甚至有的时候都下载不了,网络链接不成功. 其实,Hombrew主要分为2部分: ...

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

    0 Homebrew是啥? "Homebrew installs the stuff you need that Apple didn't.--Homebrew 使 OS X 更完整&quo ...

  3. mac php5.6.30与php7共存,认识Homebrew以及在Mac上同时安装PHP5及PHP7

    Homebrew几乎是Mac上必备的软件,用于下载安装和管理其他软件.尤其对于程序员,讲真,本人到现在仍然不知道在Mac上如何不借助Homebrew来搭建php-apache-mysql开发环境. 认 ...

  4. Mac上安装homebrew(类似于Linux上的apt-get)

    apt-get是Linux上的一个重要的工具,很多软件的安装.卸载.更新都会用到它. homebrew就是Mac上的"apt-get"啦. 但是,当前Mac上默认是没有这个工具的, ...

  5. Mac上执行命令“brew install *”时需谨慎,警惕homebrew自动更新python3.7导致第三方模块被格式化

    问题描述: 准备通过pip3 install pyenchant安装PyEnchant模块,实现识别输入字符串是否为有效英文单词的功能.结果安装后执行如下测试脚本报错ImportError : The ...

  6. 在Mac上使用Nginx和FastCGI部署Flask应用

    最近在学习Flask,本文介绍一下如何部署Flask开发的应用,同时也学习一下Nginx的使用,这只是在Mac上的一个实验. 应用 这里使用的应用就是官方的文档中给出的Flaskr. 安装Nginx ...

  7. [转] 在Mac上搭建React Native开发环境

    原文链接: http://blog.csdn.net/xiangzhihong8/article/details/53914336 概述 前面我们介绍过在window环境下开发React Native ...

  8. docker 安装nginx_使用 Docker 在你的 mac 上搭建个服务器

    前言 为什么写这篇文章呢,主要是因为现在面临着这样一个需求.就是现在有一个 接手的 VUE 项目,在生产环境跑不起来. 但是它在服务器上是部署成功的. --然后我就想看看 vue run build ...

  9. mac 上安装服务,查看服务,重启和关闭

    首先了解下的Mac的 homebrew ,官网:https://brew.sh/index_zh-cn.html 简单的说: Homebrew 能干什么? 答:使用 Homebrew 安装 Apple ...

最新文章

  1. linux windows并发模型,Linux并发服务器模型四 -- poll
  2. 剑与远征新海盗版本10章怎么去过?Boss也会随着章节、等级提升
  3. 数据库编程起别名的3中方式
  4. 【Oracle Database】数据库控制文件管理
  5. qml 鼠标点击_QML ListView在鼠标点击时不会响应
  6. jstorm 读取mysql_jstorm运维经验转载
  7. 使用scapy回放wireshark抓到的包
  8. Java服务器 dm Server
  9. 【项目调研+论文阅读】(目录)中文实体识别研究方法综述 day6
  10. iPhone 11外壳保护套曝光:噢,这个浓厚的老干部风格
  11. Cocos2d-x之绘不规则多边形
  12. ensp配置access口_华为路由交换技术 | 虚拟局域网VLAN详解与配置
  13. FM1208CPU卡读写函数说明
  14. 【程序员读论文】LeCun, Y., Bengio, Y. Hinton, G. Deep learning. *Nature* **521,** 436–444 (2015).
  15. IE浏览器无法下载文件的解决办法(windows服务器)
  16. 使用SHC命令工具加密Shell脚本
  17. win7下修改php.ini的配置路径
  18. stata 求输出相关系数矩阵命令_Stata|①Get a foot in the door
  19. springboot基础学习笔记
  20. 使用 Python3 获取网页源代码

热门文章

  1. SPIEC-EASI的微生物网络构建示例
  2. Python使用matplotlib可视化散点图、可视化两个数值变量之间的关系(Scatter plot)
  3. R语言删除ggplot可视化图中的所有x轴轴标签实战:ggplot可视化默认包含所有x轴轴标签、删除ggplot可视化图中的所有x轴轴标签实战
  4. R语言计算回归模型学生化残差(Studentized Residuals)实战:如果样本学生化残差(Studentized Residuals)绝对值大于3则是离群值
  5. 多分类学习方法、One vs. Rest、One vs. One、Many vs. Many、多输出分类
  6. 广义线性模型?链接函数?sigmoid和softmax?Logistic处理多分类问题?logistic回归处理超大数据?使用logistic和randomsearch进行组合获取最优参数组合、优缺点
  7. 2021陇南高考成绩查询,2021年陇南中考成绩公布查询时间 陇南中考成绩查询方式入口...
  8. Python踩坑指南(第二季)
  9. SparkR对R的支持情况
  10. ART基因序列生成器,究竟是做什么的?