2 cxzlzy cxzlzy 于 2016.02.12 20:00 提问

关于 Mac 上用 Homebrew 更新软件后无效的问题求助

半年以前可以用的 gtk+3 发现现在不能用了,用 homebrew 把所有软件更新了一道之后再编译就显示如下问题:

 $ gcc -o test1 test.c `pkg-config --libs --cflags gtk+-3.0`
Package 'gdk-3.0' requires 'cairo >= 1.14.0' but version of cairo is 1.12.16
test.c:1:10: fatal error: 'gtk/gtk.h' file not found
#include <gtk/gtk.h>
         ^
1 error generated.

但是我检查我的 cairo 版本发现已经是最新的 1.14.6

 e$ brew list cairo
/usr/local/Cellar/cairo/1.14.6/bin/cairo-sphinx
/usr/local/Cellar/cairo/1.14.6/bin/cairo-trace
/usr/local/Cellar/cairo/1.14.6/include/cairo/ (14 files)
/usr/local/Cellar/cairo/1.14.6/lib/libcairo-gobject.2.dylib
/usr/local/Cellar/cairo/1.14.6/lib/libcairo-script-interpreter.2.dylib
/usr/local/Cellar/cairo/1.14.6/lib/libcairo.2.dylib
/usr/local/Cellar/cairo/1.14.6/lib/cairo/ (9 files)
/usr/local/Cellar/cairo/1.14.6/lib/pkgconfig/ (13 files)
/usr/local/Cellar/cairo/1.14.6/lib/ (6 other files)
/usr/local/Cellar/cairo/1.14.6/share/gtk-doc/ (65 files)

表示要疯了 XD

2个回答

devmiao
devmiao   Ds   Rxr 2016.02.13 09:09

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.

"

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

/usr/local/Cellar/wget/1.14: 8 files, 688K, built in 2.3 minutes

由于之前使用源码方式安装过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/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存放的路径在哪里?

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 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
在我的环境上检测是这样的:

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

cxzlzy
cxzlzy 我已经有 Homebrew 了,是更新之后其他的库检测不到新版本 XD
2 年多之前 回复
devmiao
devmiao   Ds   Rxr 2016.02.13 09:10
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
mac系统升级到10.12后homebrew不能正常使用的问题
新的系统更新后对一些重要目录的权限进行了限制,原先安装的homebrew可能会出现一些问题,造成无法正常使用homebrew 附上一条安装homebrew命令/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"可尝试用这句话更改权限sudo chown -
mac homebrew 常用命令
mac 系统常用的软件安装工具就是 homebrew, 其最常用的命令如下: 安装(需要 Ruby): ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" 搜索:brew search mysql 查询:brew info mysql 主要看具体的信息,比如目前的版本,依
取消brew的自动更新
mac上使用brew install /brew cask install安装软件总是先updating HomeBrew… 速度很慢,可以在用户主目录下的shell配置文件.zshrc中添加: # brew 不自动更新 export HOMEBREW_NO_AUTO_UPDATE=true 取消自动更新brew即可...
Mac HomeBrew 使用及MongoDB安装过程
Homebrew 是Mac下得软件包管理工具,我们可以用它在我们的Mac下安装软件,卸载软件等。要是用Homebrew,首先我们要在我们的Mac下安装Homebrew,执行下面的命令进行安装: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"1 执行安装命令,安
Mac上安装homebrew(类似于Linux上的apt-get)
apt-get是Linux上的一个重要的工具,很多软件的安装、卸载、更新都会用到它。homebrew就是Mac上的“apt-get”啦。 但是,当前Mac上默认是没有这个工具的,接下来记录的是在Mac上安装homebrew的过程。安装指令:curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/
Mac系统使用Homebrew升级Git版本
原先版本  1.7.10.2 升级后版本 2.10.0 ① 打开终端,输入brew install git: DavidtekiMacBook-Air:~ du$ brew install git ② git安装完成后,输入git --version, 发现仍旧是1.7.10.2 DavidtekiMacBook-Air:~ du$ git --version git version
Mac 安装home brew出错
mark翻车经过 鹿晗公开恋情了。。。hhhh跟我没有关系,老薛Got7大法好!!!安装homebrew的时候翻车了。。。 原因大概是不懂mac得.git/config的权限,强行回忆了一波操作系统里权限管理的问题,解决了。。。翻车现场大概是这样:在terminal里输出/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com
mac上安装unrar和rar解压缩工具
问题描述: mac上默认不支持 rar压缩,但是从windows过来的很多文件,以及邮件中的附件都是通过rar的方式进行压缩的,所以考虑在mac上也能够进行解压缩rar文件 步骤:    1:首先到网站click here上下载RAR 5.10 beta 4 for Mac OS 。    2:在terminal下执行执行解压缩命令:tar xvf rarosx-5.1.b4.tar进行解压
Mac OS X 程序员利器 – Homebrew安装与使用以及python学习指南
1.什么是Homebrew? 我们能够通过终端方便的使用它安装管理苹果没有自带的UNIX相关工具软件。2.如何安装 参考GitHub地址: https://github.com/mxcl/homebrew/wiki/installation建议安装之前删除已经安装的Fink和Macports。 Homebrew使用ruby脚步安装,Mac OS X已经自带了ruby. http://brew.s
mac上安装homebrew遇到的问题(官网方法失效,本地安装方法)
1、可以翻墙直接按照官方给的方法安装,官网有。 2、不可以翻墙却直接按照官网给的方法安装,结果安装失败,且不能卸载(安装了一半就失败了,卸载也没法卸载,但是电脑里还有一些文件,这时需要删除这些文件,不然下次进行安装的时候即使方法正确一会因为这些文件的存在而冲突失败),删除这些文件 sudo rm -rf /usr/local/.git rm -rf Library .git .gitign