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/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.

"

  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/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.

Provided you haven’t put anything else in Homebrew’s prefix(brew --prefix), you can generally justrm -rf that 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 doctor will warn youabout this.

Thus it’s probably better to install your own stuff to the Cellar andthen brew link it. 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

转载于:https://www.cnblogs.com/walter371/p/4036343.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/292762.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java泛型总结

Java泛型总结 Java泛型是JDK5引入的一个新特性&#xff0c;允许在定义类和接口的时候使用类型参数&#xff08;type parameter&#xff09;。声明的类型参数在使用的时候使用具体的类型来替换。泛型最主要的应用是在JDK5中的新集合类框架中。对于泛型概念的引入&#xff0c;开发…

mysql查看日志命令_面对成百上千台服务器产生的日志,试试这款轻量级日志搬运神器!

之前我们搭建的ELK日志收集系统&#xff0c;主要是用来收集SpringBoot应用的日志。其原理是应用通过Logstash插件&#xff0c;使用TCP向Logstash传输日志&#xff0c;从而存储到Elasticsearch中去。但是有很多中间件的日志都是直接存储在文件中的&#xff0c;比如Nginx、Elasti…

单元测试 | 如何Mock IHttpClientFactory

前言编写单元测试时&#xff0c;常常需要使用Mock框架&#xff08;例如Moq&#xff09;生成测试类的依赖接口的"模拟"实现&#xff0c;并验证接口是否按预期使用&#xff1a;_mediatorMock new Mock<IMediator>();_mediatorMock.Setup(x > x.Send(It.IsAny…

跨域资源共享(CORS)--跨域ajax

几年前&#xff0c;网站开发者都因为ajax的同源策略而撞了南墙。当我们惊叹于XMLHttpRequest对象跨浏览器支持所带来的巨大进步时&#xff0c;我们很快发现没有一个方法可以使我们用JavaScript实现请求跨域访 问&#xff0c;对此我们哀叹不已。每个人在他们自己的网站上建立代理…

Wireshark和 TcpDump抓包分析心得

1. Wireshark与tcpdump介绍 Wireshark是一个网络协议检测工具&#xff0c;支持Windows平台和Unix平台&#xff0c;我一般只在Windows平台下使用Wireshark&#xff0c;如果是Linux的话&#xff0c;我直接用tcpdump了&#xff0c;因为我工作环境中的Linux一般只有字符界面&#x…

StringBuffer和StringBuilder使用方法比較

StringBuffer是字符串缓冲区&#xff0c;是一个容器。 特点&#xff1a; 1&#xff0c;长度是可变化的。2&#xff0c;能够字节操作多个数据类型。 3&#xff0c;终于会通过toString方法变成字符串。 C create U update R read D delete1&#xff0c;存储。StringBuffer append…

遇到可爱女生如何搭讪?

1 旺仔落泪▼。。。2 养狗一日&#xff0c;用狗一时&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼3 试图混进芒果里的鹦鹉&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼4 把滴滴司机的坐垫沾走了▼5 如何高效记单词&#xff08;素材来源网络&#xf…

Tomcat 上添加虚拟相对路径

为什么80%的码农都做不了架构师&#xff1f;>>> <Context docBase"D:/SHARP" path"/test" reloadable"true" /> 转载于:https://my.oschina.net/zz006/blog/754631

198道K8sDocker面试真题大汇总,全网最全八股!

最近看到两个数据&#xff0c;想跟你们分享一下&#xff1a;一是&#xff0c;目前云原生开发人员已经达680万&#xff08;SlashData数据&#xff09;&#xff1b;二是&#xff0c;云和容器技术首超Linux&#xff0c;成最受青睐技能&#xff08;Linux基金会数据&#xff09;。云…

python ctypes 指针_Python Ctypes传递.h文件中定义的结构指针。

我认为您可能缺少的是确切地知道您希望分配结构内存的位置。下面的c代码提供了一个为struct分配内存并返回指向它的指针的函数&#xff08;new_struct&#xff08;&#xff09;&#xff09;。#include #include #include typedef struct { int a; int b; } my_struct; my_st…

iptables 手册

iptables防火墙可以用于创建过滤(filter)与NAT规则。所有Linux发行版都能使用iptables&#xff0c;因此理解如何配置iptables将会帮助你更有效地管理Linux防火墙。如果你是第一次接触iptables&#xff0c;你会觉得它很复杂&#xff0c;但是一旦你理解iptables的工作原理&#x…

Android之如何看混淆后的错误日志代码

第一步&#xff1a; 找到混淆的mapping.txt文件 build -> outputs -> mapping -> release -> mapping.txt 或者&#xff1a;1项目目录的progurad下有一个mapping.txt文件 这是混淆后的名字 和原名字的映射关系。 第二步: 找到项目用的sdk依次定位到sdk -> to…

inode

硬盘的最小存储单位叫“扇区(sector)”,每个扇区存储512字节(相当于0.5kb).系统读取硬盘时&#xff0c;只会读取多个sector即一个block.block 是文件存取的最小单位block的大小为&#xff14;kb,也就是8*sector1block. inode 是存放文件的元信息&#xff0c;如文件的创建者&…

男朋友的回答可以多敷衍?

1 跟最好的朋友好到什么程度&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼2 不要在妈妈打麻将的时候要生活费&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼3 现在卖家还要发毒誓了&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼4 刘德华老师…

Android之android.os.DeadObjectException原因

问题&#xff1a; 今天看到客户的手机出现了 &#xfeff;&#xfeff;andorid.os.DeadObjectException android.os.DeadObjectException 07-13 18:28:45.398: W/System.err(32272): at android.os.BinderProxy.transact(Native Method) 原因&#xff1a; 我们项目有2个进程 …

学习Java,容易被你忽略的小细节(2)

昨天心情真的太糟糕了&#xff0c;写完《学习Java&#xff0c;值得注意你注意的问题&#xff08;1&#xff09;》之后&#xff0c;迎来些许的支持以后就是一片片的谴责。我的主页上涌现出许许多多Java方面的牛人&#xff0c;谴责我水平太低&#xff0c;写的问题太初级。搞得我非…

WPF XAML 为项目设置全局样式

全局资源样式属性App.xaml<Application.Resources><ResourceDictionary><br><ResourceDictionary.MergedDictionaries><ResourceDictionary Source"Dictionary.xaml"/></ResourceDictionary.MergedDictionaries><br><S…

controller是什么意思_SpringMVC是什么??

SpringMVC是什么&#xff1f;一&#xff0c;首先是一个MVC框架。在web模型中&#xff0c;MVC是一种很流行的框架&#xff0c;通过把Model&#xff0c;View&#xff0c;Controller分离&#xff0c;把较为复杂的web应用分成逻辑清晰的几部分&#xff0c;是为了简化开发&#xff0…

起一卦都这么凶

公元&#xff1a;2014年5月22日0时15分14秒阳8局农历&#xff1a;2014年04月24日0时15分立夏&#xff1a;2014-5-5 22:16:00 芒种&#xff1a;2014-6-6 2:32:00干支&#xff1a;甲午年己巳月癸巳日壬子时旬空&#xff1a;辰巳空戌亥空午未空寅卯空直符&#xff1a;天冲直使&am…