mac 怎么home brewmac添加path环境变量到path

90634人阅读
Mac OS X/iOS(44)
0 Homebrew是啥?
“Homebrew installs the stuff you need that Apple didn’t.——Homebrew 使 OS X 更完整”。
Homebrew的官网(多语言版本)简单明了地介绍了如何安装和使用这个工具,并提供了自己的Wiki。
1 安装Homebrew
brew的安装很简单,使用一条ruby命令即可,Mac系统上已经默认安装了ruby。
gerryyang@mba:bin$ruby --version
ruby 2.0.0p247 ( revision 41674) [universal.x86_64-darwin13]
关于安装brew的详细说明可以参考其github上的wiki说明:
Installation
The suggested and easiest way to install Homebrew is on the . 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
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 it does it too. And you have to confirm everything
it will do before it starts.
There are other ways to install Homebrew which provide you with more flexibility. They are listed below the requirements.
gerryyang@mba:~$ruby -e &$(curl -fsSL /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]
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
open /Homebrew/homebrew/wiki/Formula-Cookbook
Further help:
gerryyang@mba:~$
3 Homebrew的有趣问题
下面关于Homebrew的一些常见问题:
(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:
==& 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:
-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
to uninstall — it will only remove Homebrew and the stuff Homebrew installed leaving anything else in /usr/local alone.
Provided you haven’t put anything else in Homebrew’s prefix(brew --prefix), you can generally just rm -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/
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 common libraries, like libexpat yourself, it may cause trouble when trying to build certain Homebrew formula. As a result
brew doctor will warn you about this.
Thus it’s probably better to install your own stuff to the Cellar and then
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
$ 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:
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” -)
看来作者是个酒鬼!
(7) 关于更多地QA可以参考Homebrew的Wiki
(8) 一些常用安装推荐
gerryyang@mba:bin$brew list
Introduction to Coreutils
The GNU Core Utilities are the basic file, shell and text manipulation utilities of the GNU operating system.
These are the core utilities which are expected to exist on every operating system.
[1]&http://brew.sh/index_zh-cn.html
[2]&/Homebrew/homebrew/wiki/Installation
[3]&/Homebrew/homebrew/wiki/FAQ
[4]&/Homebrew/homebrew/wiki
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1371570次
积分:16793
积分:16793
排名:第488名
原创:433篇
译文:10篇
评论:227条
文章:14篇
阅读:86947
(1)(2)(1)(1)(1)(2)(2)(7)(7)(1)(2)(2)(2)(5)(1)(1)(2)(1)(1)(1)(3)(4)(6)(11)(8)(4)(4)(3)(3)(3)(2)(4)(2)(5)(2)(9)(2)(9)(2)(1)(1)(3)(3)(3)(1)(1)(4)(5)(3)(6)(9)(2)(1)(2)(2)(1)(2)(5)(5)(2)(3)(6)(4)(3)(1)(1)(7)(10)(20)(20)(15)(10)(7)(8)(20)(4)(3)(18)(18)(6)(20)(18)(7)(4)(18)(14)(11)1584人阅读
linux(1)
有网友表示:“没有发现类似于“linux下homebrew”的使用和安装说明。”
实际上,几乎每个 Linux 发行版都有自己的包管理器,RedHat 系的 yum,Debian 系的 apt,Gentoo 的 Portage 等,并不需要像在 Mac 上一样用一个第三方的包管理器。CentOS 属于 RedHat 系,用 yum 就好。
Homebrew在Mac下很好用。但是和 Linux 下诸多包管理器相比,Homebrew 虽然是源代码包管理器,但缺少同为源码包的 Portage 的灵活性,安装速度上也不如采用二进制包的 yum, apt 等,想不出什么值得把 Homebrew 移植到 Linux 的理由。
从另一个角度看,也可以看出在Linux下使用Homebrew意义不大,即Homebrew之所以这么设计,很大程度上是为了绕开Mac OS X系统设计中的问题。但是按Linux的标准来看,Homebrew是一个实现的很糟糕的包管理器,原因如下:
1、使用用户本身权限编译软件,而非fakeroot编译环境,带来安全隐患
2、破坏/usr/local的权限(和内容)
3、和系统本身的软件包常常冲突
4、很多软件仍然需要大量重编译
5、由于依赖OS X的库,升级系统很容易带来软件包乃至homebrew自身的运行问题
6、存在可以实现homebrew的软件包管理器,没有必要继续重造轮子
总结:主流的Linux版本都有自己的包管理工具,没有必要把homebrew移植到Linux平台
但如果非要移植到Linux上,具体安装方法如下:
在终端输入如下指令:
ruby -e “$(curl -fsSL )”
~/.linuxbrew
再添加 .bashrc 或 .zshrc即可:
export PATH=”HOME/.linuxbrew/bin:PATH”
export MANPATH=”HOME/.linuxbrew/share/man:MANPATH”
export INFOPATH=”HOME/.linuxbrew/share/info:INFOPATH”
参考网址:
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:140844次
积分:2749
积分:2749
排名:第11335名
原创:120篇
转载:26篇
评论:43条
阅读:2318
文章:13篇
阅读:20866
(6)(3)(22)(35)(3)(7)(11)(13)(13)(4)(7)(24)(8)

我要回帖

更多关于 mac添加path环境变量 的文章

 

随机推荐