快乐的鲸鱼

Homebrew 使用记录

2015/12/07

Homebrew 真的是OS X平台下很好用的软件管理工具

安装

因为Homebrew 是使用ruby 脚本,所以可以在终端用ruby 脚本安装

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

使用

1
2
3
4
5
//安装软件
brew install wget

//卸载软件
brew uninstall wget

错误提示及其解决

1
2
3
4
Error: Permission denied - /Library/Caches/Homebrew/Formula/...

解决办法:
sudo chown -R $USER /Library/Caches/Homebrew/

更换国内源

1
2
3
4
5
6
7
8
9
10
11
12
13
cd /usr/local
//中科大镜像源
git remote set-url origin http://mirrors.ustc.edu.cn/homebrew.git

cd ~
mkdir tmp
cd tmp
git clone http://mirrors.ustc.edu.cn/homebrew.git

sudo rm -rf /usr/local/.git
sudo rm -rf /usr/local/Library
sudo cp -R homebrew/.git /usr/local/
sudo cp -R homebrew/Library /usr/local/

排错

如果你遇到如下问题:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
╰─➤  brew update
Stashing your changes:
M .gitignore
M .yardopts
M README.md
M share/doc/homebrew/Acceptable-Formulae.md
M share/doc/homebrew/Common-Issues.md
M share/doc/homebrew/FAQ.md
M share/doc/homebrew/Formula-Cookbook.md
M share/doc/homebrew/Homebrew-0.9.3.md
M share/doc/homebrew/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md
D share/doc/homebrew/How-to-Create-and-Maintain-a-Tap.md
M share/doc/homebrew/How-to-build-software-outside-Homebrew-with-Homebrew-keg-only-dependencies.md
M share/doc/homebrew/Installation.md
M share/doc/homebrew/Interesting-Taps-&-Branches.md
M share/doc/homebrew/Maintainer-Guidelines.md
M share/doc/homebrew/Press.md
M share/doc/homebrew/Python-for-Formula-Authors.md
M share/doc/homebrew/Querying-Brew.md
M share/doc/homebrew/README.md
D share/doc/homebrew/Rename-A-Formula.md
M share/doc/homebrew/Troubleshooting.md
M share/doc/homebrew/Xcode.md
M share/doc/homebrew/brew-tap.md
M share/man/man1/brew.1
fatal: Unable to create '/usr/local/.git/index.lock': Permission denied
Cannot save the current index state
Error: Failure while executing: git stash save --include-untracked --quiet

就输入以下命令

1
2
3
4
sudo chgrp -R admin /usr/local
//确保目录归属管理组
sudo chmod -R g+w /usr/local
//确保管理组可读

最后便可以运行brew update 和 brew upgrade

CATALOG
  1. 1. 安装
  2. 2. 使用
  3. 3. 错误提示及其解决
  4. 4. 更换国内源
    1. 4.1. 排错