HomeBrew

2023-05-16

搜索软件:brew search 软件名,如brew search wget

安装软件:brew install 软件名,如brew install wget

卸载软件:brew remove 软件名,如brew remove wget

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.   
  5.     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.   
  12. Troubleshooting:  
  13.   brew doctor  
  14.   brew install -vd FORMULA  
  15.   brew [--env | --config]  
  16.   
  17. Brewing:  
  18.   brew create [URL [--no-fetch]]  
  19.   brew edit [FORMULA...]  
  20.   open https://github.com/Homebrew/homebrew/wiki/Formula-Cookbook  
  21.   
  22. Further help:  
  23.   man brew  
  24.   brew home  
  25.   
  26. 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.   
  11. Possible conflicting files are:  
  12. /usr/local/bin/wget  
  13. /usr/local/share/man/man1/wget.1  
  14. ==> Summary  
  15. <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.   
  12. Mac OS X already provides this software and installing another version in  
  13. parallel can cause all kinds of trouble.  
  14.   
  15. The OpenSSL provided by OS X is too old for some software.  
  16.   
  17. Generally there are no consequences of this for you. If you build your  
  18. own software and it requires this formula, you'll need to add to your  
  19. build variables:  
  20.   
  21.     LDFLAGS:  -L/usr/local/opt/openssl/lib  
  22.     CPPFLAGS: -I/usr/local/opt/openssl/include  
  23.   
  24. ==> security find-certificate -a -p /Library/Keychains/System.keychain > '/usr/l  
  25. ==> security find-certificate -a -p /System/Library/Keychains/SystemRootCertific  
  26. ==> mv -f /usr/local/etc/openssl/osx_cert.pem.tmp /usr/local/etc/openssl/osx_cer  
  27. ==> Summary  
  28. /usr/local/Cellar/openssl/1.0.1f: 429 files, 15M  
  29. ==> Installing wget  
  30. ==> Downloading http://ftpmirror.gnu.org/wget/wget-1.15.tar.gz  
  31. ######################################################################## 100.0%  
  32. ==> ./configure --prefix=/usr/local/Cellar/wget/1.15 --sysconfdir=/usr/local/etc --with-ssl=openssl --with-libssl-prefix=/usr/local/opt/openssl --disable-iri  
  33. ==> make install  
  34. Warning: Could not link wget. Unlinking...  
  35. Error: The `brew link` step did not complete successfully  
  36. The formula built, but is not symlinked into /usr/local  
  37. You can try again using `brew link wget'  
  38.   
  39. Possible conflicting files are:  
  40. /usr/local/bin/wget  
  41. /usr/local/share/man/man1/wget.1  
  42. ==> Summary  
  43. /usr/local/Cellar/wget/1.15: 8 files, 700K, built in 73 seconds  
  44. 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.   
  10. 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.   
  6. Unexpected dylibs:  
  7.     /usr/local/lib/libboost_atomic.dylib  
  8.     /usr/local/lib/libboost_chrono.dylib  
  9.     /usr/local/lib/libboost_context.dylib  
  10.     /usr/local/lib/libboost_date_time.dylib  
  11.     /usr/local/lib/libboost_filesystem.dylib  
  12.     /usr/local/lib/libboost_graph.dylib  
  13.     /usr/local/lib/libboost_iostreams.dylib  
  14.     /usr/local/lib/libboost_locale.dylib  
  15.     /usr/local/lib/libboost_log.dylib  
  16.     /usr/local/lib/libboost_math_c99.dylib  
  17.     /usr/local/lib/libboost_math_c99f.dylib  
  18.     /usr/local/lib/libboost_math_c99l.dylib  
  19.     /usr/local/lib/libboost_math_tr1.dylib  
  20.     /usr/local/lib/libboost_math_tr1f.dylib  
  21.     /usr/local/lib/libboost_math_tr1l.dylib  
  22.     /usr/local/lib/libboost_prg_exec_monitor.dylib  
  23.     /usr/local/lib/libboost_program_options.dylib  
  24.     /usr/local/lib/libboost_python.dylib  
  25.     /usr/local/lib/libboost_random.dylib  
  26.     /usr/local/lib/libboost_regex.dylib  
  27.     /usr/local/lib/libboost_serialization.dylib  
  28.     /usr/local/lib/libboost_signals.dylib  
  29.     /usr/local/lib/libboost_system.dylib  
  30.     /usr/local/lib/libboost_thread.dylib  
  31.     /usr/local/lib/libboost_timer.dylib  
  32.     /usr/local/lib/libboost_unit_test_framework.dylib  
  33.     /usr/local/lib/libboost_wave.dylib  
  34.     /usr/local/lib/libboost_wserialization.dylib  
  35.   
  36. Warning: Unbrewed static libraries were found in /usr/local/lib.  
  37. If you didn't put them there on purpose they could cause problems when  
  38. building Homebrew formulae, and may need to be deleted.  
  39.   
  40. Unexpected static libraries:  
  41.     /usr/local/lib/libboost_atomic.a  
  42.     /usr/local/lib/libboost_chrono.a  
  43.     /usr/local/lib/libboost_context.a  
  44.     /usr/local/lib/libboost_coroutine.a  
  45.     /usr/local/lib/libboost_date_time.a  
  46.     /usr/local/lib/libboost_exception.a  
  47.     /usr/local/lib/libboost_filesystem.a  
  48.     /usr/local/lib/libboost_graph.a  
  49.     /usr/local/lib/libboost_iostreams.a  
  50.     /usr/local/lib/libboost_locale.a  
  51.     /usr/local/lib/libboost_log.a  
  52.     /usr/local/lib/libboost_math_c99.a  
  53.     /usr/local/lib/libboost_math_c99f.a  
  54.     /usr/local/lib/libboost_math_c99l.a  
  55.     /usr/local/lib/libboost_math_tr1.a  
  56.     /usr/local/lib/libboost_math_tr1f.a  
  57.     /usr/local/lib/libboost_math_tr1l.a  
  58.     /usr/local/lib/libboost_prg_exec_monitor.a  
  59.     /usr/local/lib/libboost_program_options.a  
  60.     /usr/local/lib/libboost_python.a  
  61.     /usr/local/lib/libboost_random.a  
  62.     /usr/local/lib/libboost_regex.a  
  63.     /usr/local/lib/libboost_serialization.a  
  64.     /usr/local/lib/libboost_signals.a  
  65.     /usr/local/lib/libboost_system.a  
  66.     /usr/local/lib/libboost_test_exec_monitor.a  
  67.     /usr/local/lib/libboost_thread.a  
  68.     /usr/local/lib/libboost_timer.a  
  69.     /usr/local/lib/libboost_unit_test_framework.a  
  70.     /usr/local/lib/libboost_wave.a  
  71.     /usr/local/lib/libboost_wserialization.a  
  72.   
  73. Warning: You have unlinked kegs in your Cellar  
  74. Leaving kegs unlinked can lead to build-trouble and cause brews that depend on  
  75. those kegs to fail to run properly once built. Run `brew link` on these:  
  76.   
  77.     wget  
  78. 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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

HomeBrew 的相关文章

随机推荐

  • RabbitMQ知多少

    1 引言 RabbitMQ Rabbit Message Queue的简写 xff0c 但不能仅仅理解其为消息队列 xff0c 消息代理更合适 RabbitMQ 是一个由 Erlang 语言开发的AMQP xff08 高级消息队列协议 xf
  • 远程控制软件VNC教程和对内网机器控制的实现

    远程控制软件VNC教程和对内网机器控制的实现 作者 Hoky ORG 出处 Hoky ORG 77 砖 82 好 评论 12 条 进入论坛 更新时间 xff1a 2006 01 25 16 02 关 键 词 xff1a 远程控制软件VNC
  • MariaDB 10.3支持update多表ORDER BY and LIMIT

    MariaDB 10 3支持update多表ORDER BY and LIMIT 1 xff09 update连表更新 xff0c limit语句 update t1 join t2 on t1 id 61 t2 id set t1 nam
  • 细胞自动机

    细胞自动机是指定形状的网格上的 有色 单元的集合 xff0c 其根据基于相邻单元的状态的一组规则通过多个离散时间步长演变 然后根据需要迭代地应用规则多个时间步长 冯 诺伊曼是最早考虑这种模型的人之一 xff0c 并将细胞模型纳入他的 通用构
  • centos 常见故障排除

    centos 常见故障排除 实现环境 xff1a Centos x86 64 1 MBR故障和解决办法 xff08 1 xff09 模拟MBR故障 第一步 xff1a MBR中bootloader有446个字节 xff0c 在这里把这446
  • manjaro linux必装工具,在Manjaro系统中安装常用软件的方法

    本文介绍在Manjaro系统中安装一些常用的软件 xff0c 有vim chrome 截图 TIM 网易云音乐 搜狗输入法 markdown编辑器 pdf阅读器 steam git客户端 下载工具uget 视频播放器 zsh 前言 更换为中
  • 10款基于HTML5+CSS3实现的超酷源码动画

    1 基于Bootstrap的jQuery登录表单 这是一款基于Bootstrap的登录表单 xff0c 表单的外观自然不用说 xff0c 沿用了Bootstrap的风格 xff0c 非常漂亮 这款登录表单有一个经过CSS3处理过的头像图片
  • Spring AOP 对Spring MVC的Controller切面拦截不起作用

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 1 问题描述 当使用Spring AOP对Controller层的Controller类的方法进行切面拦截 xff0c 不起作用 AOP配置没有任何问题 2 排查过程 Sp
  • 2008年9月全国计算机等级考试二级C笔试试卷

    2008 年9月全国计算机等级考试二级C笔试试卷 一 选择题 1 一个栈的初始状态为空 现将元素1 2 3 4 5 A B C D E依次入栈 xff0c 然后在依次出栈 xff0c 则元素出栈的顺序是 B A xff09 12345ABC
  • 如何学习一门计算机编程语言

    序言 计算机编程是一个实践性很强的 游戏 xff0c 对于新入门者 xff0c 好多人都在想 xff0c 哪一门编程语言最好 xff0c 我该从哪开始呢 xff1f 我的回答是 xff1a 语言不重要 xff0c 理解编程思想才是最关键的
  • CentOS6 Shell脚本/bin/bash^M: bad interpreter错误解决方法

    为什么80 的码农都做不了架构师 xff1f gt gt gt 在windows下保存了一个脚本文件 xff0c 用ssh上传到centos xff0c 添加权限执行nginx提示没有那个文件或目录 shell脚本放到 etc init d
  • 微软面试题

    1 求函数返回值 xff0c 输入 x 61 9999 int func x int countx 61 0 while x countx 43 43 x 61 x amp x 1 return countx 试题解析 解这道题的时候 xf
  • hexo常用命令笔记

    hexo 皮肤Github hexo 皮肤预览 hexo bashnpm install hexo g 安装 npm update hexo g 升级 hexo init 初始化 简写 hexo n 34 我的博客 34 61 61 hex
  • 什么是MariaDB中的thread pool,连接池简介

    Thread pool是什么 MySQL是每个连接上来都要创建一个线程来执行语句 这样每一个新的连接进来即会创建一个新的线程 xff0c 这种动作对MySQL本身压力比较大 Threadpool是提供一种线程代理的模型执行每个连接的语句 而
  • 程序员工作5年以上,找工作还看学历吗?

    很多程序员都有这样的觉悟 xff1b 找工作学历是敲门砖 xff0c 没有211 985起步的学历 xff0c 想进一家大公司不太可能 举个例子好了 xff1b 如果你是大厂面试官 xff0c 参与面试的有10个刚刚毕业没有工作经验的普通学
  • win10下VirtualBox虚拟机开机后台自启动

    每次使用linux的时候 xff0c 都是打开virtualBox gt 启动安装的linux系统 gt 再用远程桌面 xff08 SSH等 xff09 连接 xff0c 每次手动打开比较麻烦 xff0c 而且linux虚拟机也有窗口 xf
  • 审批流程数据库设计

    要做一个通用的流程系统 xff0c 大概应建立如下数据表 xff1a 1 流程表 xff08 tbl flow xff09 字段名数据类型备注flow idint流程编号 xff0c 主键flow noint流程号 xff0c 唯一列flo
  • 【Wax】使用Wax (framework方式,XCode 4.6)

    前情提示 xff1a Wax 使用Wax xff08 非framework方式 xff0c XCode 4 6 xff09 这次 xff0c 将以framework的方式来使用Wax 那么 xff0c 让我们开始吧 xff01 xff01
  • Spring Boot利用AOP获取用户操作实现日志记录

    环境 xff1a IDEA版本2017 3 1 x64 xff0c JDK1 8 xff0c SpringBoot2 1 1 xff0c Druid1 1 8 xff0c mybatis1 3 2 xff0c Security5 1 2 x
  • HomeBrew

    搜索软件 xff1a brew search 软件名 xff0c 如brew search wget 安装软件 xff1a brew install 软件名 xff0c 如brew install wget 卸载软件 xff1a brew