mac下的包管理器--Homebrew

centOS下有yum,ubuntu下有apt,习惯了使用包管理器安装工具和其依赖,所以mac下可以使用Homebrew。

Homebrew官网:http://brew.sh

在终端下执行命令即可自动完成安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

常用命令:

1.查询:brew search wget  或者使用正则 brew search /wget.*/

2.安装:brew install wget :安装的所有软件都在/usr/local/Cellar目录下,相应的命令被软连接到/usr/local/bin下,查看/etc/paths,如果/usr/local/bin在最上面,说明这个命令里的命令优先被系统检索使用。

3.卸载:brew uninstall wget

4.列出使用brew已经安装的全部软件:brew list

5.更新brew:brew update

6.显示依赖包:brew deps wget #显示wget的依赖包,比如openssl

7.显示软件信息:brew info wget

8.列出软件安装路径:brew list wget #安装完成后会使用软连接到/usr/local/bin下

9.用浏览器打开软件的官网:brew home wget   #brew home会打开Homebrew的官网

10.升级软件:brew upgrade wget

github网站有ip访问次数限制,多次调用brew命令后会提示如下错误:

Error: GitHub API Error: API rate limit exceeded for 114.111.167.230. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
Try again in 44 minutes 38 seconds, or create a personal access token:
  https://github.com/settings/tokens/new?scopes=&description=Homebrew
and then set the token as: export HOMEBREW_GITHUB_API_TOKEN="your_new_token"

 按照提示访问相应的网站,注册个帐号,然后生成一个token,并导入到环境变量中。

另外,执行brew update命令时,报如下错误:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
 这和升级了macOS系统有关系,可以执行命令:xcode-select --install,在弹出的软件安装界面中点击安装即可解决该问题。

另外,这个时候也会提示你需要对当前用户进行授权:sudo chown -R username /usr/local ,执行完brew update后,会提示你修改回原来的权限:sudo chown root:wheel /usr/local

猜你喜欢

转载自hanqunfeng.iteye.com/blog/2320170