homebrew link で Permission denied

Written by じび on 11月 28th, 2012

MacBook に git をインストールしていたが、 Mac OS X 10.8 Mountain Linon にアップデートしたら、以下のようにエラーを出して動かなくなった。

$ git
-bash: /usr/local/bin/git: Bad CPU type in executable

完全64bit化されて、32bitのアプリは弾かれているのか?
とりあえずgitをアップデートする。
gitはソースからコンパイルしてインストールしていたが、この際なので homebrew を使ってみる事にした。

homebrew のインストールはうまく行ったのだが、その上で git をインストールしようとすると、以下のエラーが出て失敗する。

Warning: Could not link git. 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 git'
==> Summary
/usr/local/Cellar/git/1.8.0.1: 1251 files, 24M, built in 2.2 minutes

ならばと brew link git を実行してみるも、以下のエラーで失敗。

$ brew link git
Linking /usr/local/Cellar/git/1.8.0.1... Warning: Could not link git. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/git/1.8.0.1/bin/gitk
Target /usr/local/bin/gitk already exists. You may need to delete it.
To force the link and delete this file, do:
brew link --overwrite formula_name

To list all files that would be deleted:
brew link --overwrite --dry-run formula_name
$

指示通りに brew link –overwrite を使うも、以下のエラー。

$ brew link --overwrite git
Linking /usr/local/Cellar/git/1.8.0.1... Warning: Could not link git. Unlinking...

Error: Permission denied - /usr/local/share/gitk/lib/msgs/sv.msg
$

色々調べてみると homebrew を使う場合は /usr/local/ をグループ:staff、パーミッション:775に設定しておく必要がある模様。

参考:

なので、以下のコマンドを実行。

$ sudo chgrp -R staff /usr/local
$ sudo chmod -R 775 /usr/local
$

これで brew link –overwrite git が成功し、git のインストールが完了した。

 

Leave a Comment