brew: MacOS的包管理工具

匿名 (未验证) 提交于 2019-12-03 00:30:01


brew是MacOS上的包管理工具,像RHEL/CentOS上的yum或者Ubuntu上的apt-get一样,MacOS上使用brew也可以非常容易进行包的管理。

项目 说明
官方网站 https://brew.sh
开源/闭源 开源
License类别 BSD 2-Clause “Simplified” License
代码管理地址 https://github.com/Homebrew/brew
开发语言 Ruby
支持平台 MacOS
当前版本 1.6.9 (2018/06/18)

因为brew是ruby开发的,需要使用确认ruby已经安装,缺省状况下是已经安装的。

liumiaocn:~ liumiao$ which ruby /usr/bin/ruby liumiaocn:~ liumiao$ ruby -v ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17] liumiaocn:~ liumiao$ 

具体的安装脚本在raw.githubusercontent.com已有,使用如下命令即可安装

安装命令:ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

liumiaocn:~ liumiao$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"  ==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew ==> The following existing directories will be made group writable: /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 ==> The following existing directories will have their owner set to liumiao: /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 ==> The following existing directories will have their group set to admin: /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7  Press RETURN to continue or any other key to abort ==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 Password: ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 ==> /usr/bin/sudo /usr/sbin/chown liumiao /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 ==> Downloading and installing Homebrew... remote: Counting objects: 103258, done. remote: Total 103258 (delta 0), reused 0 (delta 0), pack-reused 103257 Receiving objects: 100% (103258/103258), 23.47 MiB | 22.00 KiB/s, done. Resolving deltas: 100% (75270/75270), done. From https://github.com/Homebrew/brew  * [new branch]          master     -> origin/master ...省略  * [new tag]             1.6.9      -> 1.6.9 HEAD is now at 25542d739 Merge pull request #4316 from reitermarkus/merge-search ==> Tapping homebrew/core Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'... fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': Could not resolve host: github.com Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1 Error: Failure while executing: /usr/local/bin/brew tap homebrew/core Failed during: /usr/local/bin/brew update --force liumiaocn:~ liumiao$

由于网络等的问题,往往容易出错,再次执行:

liumiaocn:~ liumiao$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"  ==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew  Press RETURN to continue or any other key to abort ==> Downloading and installing Homebrew... HEAD is now at 25542d739 Merge pull request #4316 from reitermarkus/merge-search ==> Tapping homebrew/core Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'... remote: Counting objects: 4788, done. remote: Compressing objects: 100% (4562/4562), done. remote: Total 4788 (delta 56), reused 1038 (delta 38), pack-reused 0 Receiving objects: 100% (4788/4788), 3.88 MiB | 45.00 KiB/s, done. Resolving deltas: 100% (56/56), done. Tapped 4576 formulae (4,829 files, 12.2MB) ==> Cleaning up /Library/Caches/Homebrew... ==> Migrating /Library/Caches/Homebrew to /Users/liumiao/Library/Caches/Homebrew... ==> Deleting /Library/Caches/Homebrew... Already up-to-date. ==> Installation successful!  ==> Homebrew has enabled anonymous aggregate user behaviour analytics. Read the analytics documentation (and how to opt-out) here:   https://docs.brew.sh/Analytics.html  ==> Next steps: - Run `brew help` to get started - Further documentation:      https://docs.brew.sh liumiaocn:~ liumiao$ 
liumiaocn:~ liumiao$ brew -v Homebrew 1.6.9 Homebrew/homebrew-core (git revision cf4d; last commit 2018-06-19) liumiaocn:~ liumiao$

使用brew可以进行包的查询/安装/卸载等常见操作:

子命令 说明
info 确认包的安装状况
install 安装包
uninstall 卸载包
update 更新包
list 确认已经安装的包的状况
doctor 检测冲突

比如使用brew install wget进行wget的安装

liumiaocn:~ liumiao$ brew list gdbm        jpeg        libpng      libunistring    pkg-config  readline    wget        wxpython gettext     libidn2     libtiff     openssl     python@2    sqlite      wxmac liumiaocn:~ liumiao$
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!