done is better than perfect

自分が学んだことや、作成したプログラムの記事を書きます。すべての記載は他に定める場合を除き個人的なものです。

homebrewをアップデートしようとしたらエラーが出た

久しぶりにMacのHomebrewをupdateしようかなと思ったら、エラーが出ました。
$ brew update
error: Your local changes to the following files would be overwritten by merge:
CONTRIBUTING.md
Library/Contributions/brew_bash_completion.sh
…
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
特にhomebrewの設定をいじったつもりはないんだけどな、と思いつつエラーメッセージでググったらこちらのサイトが出て来ました。 サイトの情報を参考にして
$ cd /usr/local
$ git checkout .
と打ちます。これで、homebrew本家の内容とローカルの内容が同一のものになったと思います。ちなみに
$ git checkout .
は、作業ツリーの変更を全て元に戻すgitコマンドです。 変更も戻して、もう一回homebrewをupdateしようとすると、まだエラーが
$ brew update
error: The following untracked working tree files would be overwritten by merge:
Library/Aliases/heroku
…
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
更にググると、stackoverflowで似たような質問がありました。 参考にしつつ、今度は下記のコマンドを打ってみます。
$ cd /usr/local
$ git fetch origin
$ git reset --hard origin/master
これでupdateすると
$ brew update
Already up-to-date.
エラーが無くなりました。ってかアップデートなかったのか…… 心配なので、homebrewの自己診断してみると
$ 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.
…
Warning: Your compilers are different from the standard versions for your Xcode.
If you have Xcode 4.3 or newer, you should install the Command Line Tools for
Xcode from within Xcode's Download preferences.
Otherwise, you should reinstall Xcode.
いっぱいエラーが(´;ω;`) 取り敢えず、一旦ここで諦めた。エラー内容見ると、/usr/local/にhomebrew以外の方法でインストールするとWarningが出るらしい。ということで次の記事に解決編を載せます。