Mac OS X Yosemite で brew コマンドを実行しようとするとエラーが発生しました。
エラー内容
% brew -h
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 21: /usr/local/Library/brew.rb: Undefined error: 0
まず、下記のように ruby の path を 1.8 から current へ変更します。
git diff
diff --git a/Library/brew.rb b/Library/brew.rb
index 4fa22b4..ee05650 100755
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -1,4 +1,4 @@
-#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
+#!/System/Library/Frameworks/Ruby.framework/Versions/current/usr/bin/ruby -W0
# encoding: UTF-8
std_trap = trap("INT") { exit! 130 } # no backtrace thanks
次に brew の git repository へ移動して、修正内容を commit します。
cd $(brew --prefix)
git add .
git commit -m 'Change the path for ruby'
brew update
最後に git commit をしておかないと brew update したときに下記のようにエラーでアップデートできません。
% brew update
error: Your local changes to the following files would be overwritten by merge:
Library/Formula/mongodb.rb
Please, commit your changes or stash them before you can merge.
error: Your local changes to the following files would be overwritten by merge:
Library/brew.rb
Please, commit your changes or stash them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
brew update で盛大に conflict したときは手元の修正は捨てて、
git reset --hard HEAD
git merge -Xtheirs origin/master
してしまえば OK です。