HomeBrewでMacVimがコンパイルできないのを修正する

MacVimがアップデートされたみたいなのでインストールしようとしたら、以下の様なエラーが起きてしまった。修正する方法を調べたので、まとめておく。

$ brew upgrade macvim 
==> Upgrading macvim
==> Downloading https://github.com/b4winckler/macvim/tarball/snapshot-64
Already downloaded: /Library/Caches/Homebrew/macvim-7.3-64.tgz
==> ./configure --with-features=huge --with-tlib=ncurses --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --
==> make getenvy
==> make
...
xcodebuild -project MacVim/MacVim.xcodeproj ARCHS="x86_64" ONLY_ACTIVE_ARCH="NO"
Error: No developer directory found at /Developer. Run /usr/bin/xcode-select to update the developer directory path.
make[1]: *** [macvim] Error 1
make: *** [first] Error 2
==> Build Environment
HOMEBREW_VERSION: 0.9.2
HEAD: c8692b443fbf515a1baad063ee27c57be1800b5b
CPU: quad-core 64-bit sandybridge
OS X: 10.7.4-x86_64
Xcode: 4.4.1
CLT: 1.0.0.9000000000.1.1249367152
X11: XQuartz 2.6.4 in /usr/X11
CC: /usr/bin/clang
CXX: /usr/bin/clang++ => /usr/bin/clang
LD: /usr/bin/clang
CFLAGS: -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7
CXXFLAGS: -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7
CPPFLAGS: -isystem /usr/local/include
LDFLAGS: -L/usr/local/lib
MAKEFLAGS: -j4
MACOSX_DEPLOYMENT_TARGET: 10.7
OBJC: /usr/bin/clang
PATH: /Users/*****/bin:/Users/*****/pear/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin:/Developer/usr/bin:/usr/local/Library/Contributions/cmds
Error: Failed executing: make (macvim.rb:63)
This may help you fix or report the issue if `brew doctor` does not:
    https://github.com/mxcl/homebrew/wiki/bug-fixing-checklist

エラーの内容は以下の通りで、Xcodeのバージョンが上がった為にエラーになっているようです。

Error: No developer directory found at /Developer. Run /usr/bin/xcode-select to update the developer directory path.

という事でxcode-selectを使ってパスを修正します。

$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Password:
$ /usr/bin/xcode-select -print-path
/Applications/Xcode.app/Contents/Developer
$ brew upgrade macvim 
==> Upgrading macvim
==> Downloading https://github.com/b4winckler/macvim/tarball/snapshot-64
Already downloaded: /Library/Caches/Homebrew/macvim-7.3-64.tgz
==> ./configure --with-features=huge --with-tlib=ncurses --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --
==> make getenvy
==> make
==> Caveats
MacVim.app installed to:
  /usr/local/Cellar/macvim/7.3-64

To link the application to a normal Mac OS X location:
    brew linkapps
or:
    ln -s /usr/local/Cellar/macvim/7.3-64/MacVim.app /Applications
==> Summary
/usr/local/Cellar/macvim/7.3-64: 1733 files, 26M, built in 78 seconds
$ brew linkapps
Linking /usr/local/Cellar/macvim/7.3-64/MacVim.app
Finished linking. Find the links under ~/Applications.