Yosemiteにアップデート後にbrew installが失敗する
ただちょっとこの端末にtreeコマンドが入ってなかったのでbrewで入れたかっただけなんだけど、brew install失敗するので調べたらYosemiteアップデートが原因だった件。
brew installするとこんなかんじでエラーが出ます。
$ brew install tree /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 23: /usr/local/Library/brew.rb: Undefined error: 0
なんかrubyのパスが見つからないっぽいエラーが出てるのでググったところ、/usr/local/Library/brew.rbを編集して1.8をCurrentに変えろとの情報があり。
homebrewユーザーがYosemiteにアプグレしたらbrewコマンドが使えなくなった問題解決法 - いろいろ研究所
(変更前)
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
(変更後)
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
で、気を取り直してbrew installすると再度エラーが。
$ brew install tree ==> Downloading http://mama.indstate.edu/users/ice/tree/src/tree-1.7.0.tgz ######################################################################## 100.0% ==> make prefix=/usr/local/Cellar/tree/1.7.0 MANDIR=/usr/local/Cellar/tree/1.7.0 /usr/local/Library/ENV/4.3/make: /usr/local/Library/ENV/4.3/xcrun: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory /usr/local/Library/ENV/4.3/make: line 3: /usr/local/Library/ENV/4.3/xcrun: Undefined error: 0 Error: Homebrew doesn't know what compiler versions ship with your version of Xcode (6.1.1). Please `brew update` and if that doesn't help, file an issue with the output of `brew --config`: https://github.com/Homebrew/homebrew/issues Note that we only track stable, released versions of Xcode. Thanks! Error: No such file or directory - /usr/local/Library/ENV/4.3/gcc-4.2
Xcode6.1.1とか知らないのでbrew updateしてみろと出てるので、brew updateするとupdateも失敗。
$ brew update 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
内部でgit使っていて、勝手にLibrary/brew.rb編集したからmergeできないと。えー。内部でgit使ってたんっすか。普通勝手に編集したりしないので今まで知らんかったよ。
もうちょっとググると確かに同じような症状の人が。単にcommitしちゃえばよいよう。
Yosemiteでbrewが壊れた - Qiita
$ cd /usr/local $ git add Library/brew.rb $ git commit -m "Fix brew.rb for yosemite update" $ brew update
お、ちゃんとupdateできた。気を取り直して
brew install tree
で、brew installもできるように治った。