Mavericksにアップデート後、brewのパスが消えた


基本的に、以下のコマンドででパスを作りなおすと治るらしいのだが、エラーが出たのでメモ。

```
brew list | xargs brew unlink
brew list | xargs brew link
```



```
brew list | xargs brew unlink
Unlinking /usr/local/Cellar/autoconf/2.69... 0 symlinks removed
Unlinking /usr/local/Cellar/cmake/3.0.0... 0 symlinks removed
Unlinking /usr/local/Cellar/freetype/2.5.0.1... 1 symlinks removed
Unlinking /usr/local/Cellar/gauche/0.9.3.3... 20 symlinks removed
Unlinking /usr/local/Cellar/gdbm/1.11... 0 symlinks removed
Unlinking /usr/local/Cellar/git/1.8.4.3... 40 symlinks removed
Unlinking /usr/local/Cellar/imagemagick/6.8.7-0... 26 symlinks removed
Unlinking /usr/local/Cellar/jpeg/8d... 0 symlinks removed
Unlinking /usr/local/Cellar/libevent/2.0.21... 3 symlinks removed
Unlinking /usr/local/Cellar/libpng/1.6.12... 2 symlinks removed
Unlinking /usr/local/Cellar/libtiff/4.0.3... 1 symlinks removed
Unlinking /usr/local/Cellar/libtool/2.4.2... 0 symlinks removed
Unlinking /usr/local/Cellar/libyaml/0.1.4... 1 symlinks removed
Unlinking /usr/local/Cellar/node/0.10.22... 1287 symlinks removed
Unlinking /usr/local/Cellar/opencv/2.4.9... 4 symlinks removed
Unlinking /usr/local/Cellar/openssl/1.0.1h... 0 symlinks removed
Unlinking /usr/local/Cellar/pkg-config/0.28... 0 symlinks removed
Unlinking /usr/local/Cellar/play/2.2.1... 0 symlinks removed
Unlinking /usr/local/Cellar/python/2.7.7_2... 8 symlinks removed
Unlinking /usr/local/Cellar/rbenv/0.4.0... 0 symlinks removed
Unlinking /usr/local/Cellar/readline/6.3.6... 0 symlinks removed
Unlinking /usr/local/Cellar/ruby-build/20131122.1... 0 symlinks removed
Unlinking /usr/local/Cellar/scala/2.10.3... 1 symlinks removed
Unlinking /usr/local/Cellar/sqlite/3.8.5... 0 symlinks removed
Unlinking /usr/local/Cellar/tmux/1.8... 2 symlinks removed
Unlinking /usr/local/Cellar/tree/1.6.0... 0 symlinks removed
Unlinking /usr/local/Cellar/wget/1.14... 0 symlinks removed
meganii-air:~ meganii$ brew list | xargs brew link
Error: freetype has multiple installed versions
meganii-air:~ meganii$ brew list | xargs brew unlink
Error: freetype has multiple installed versions
meganii-air:~ meganii$ brew install freetype
Error: You must `brew link libpng' before freetype can be installed
meganii-air:~ meganii$ brew link libpng
Linking /usr/local/Cellar/libpng/1.6.12... 18 symlinks created
meganii-air:~ meganii$ brew install freetype
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/freetype-2.
######################################################################## 100.0%
==> Pouring freetype-2.5.3_1.mavericks.bottle.1.tar.gz
```


```
brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours, this is a long time in brewland!
To update Homebrew, run `brew update`.

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours, this is a long time in brewland!
To update Homebrew, run `brew update`.
```

Error: freetype has multiple installed versions
meganii-air:~ meganii$ brew list | xargs brew unlink
Error: freetype has multiple installed versions
meganii-air:~ meganii$ brew install freetype
Error: You must `brew link libpng' before freetype can be installed
meganii-air:~ meganii$ brew link libpng
Linking /usr/local/Cellar/libpng/1.6.12... 18 symlinks created
meganii-air:~ meganii$ brew install freetype
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/freetype-2.
######################################################################## 100.0%
==> Pouring freetype-2.5.3_1.mavericks.bottle.1.tar.gz
?  /usr/local/Cellar/freetype/2.5.3_1: 60 files, 2.5M




まず、`brew list | xargs brew unlink`を実行すると、以下のエラーが出た。
`Error: git has multiple installed versions`

brew doctor
brew cleanup

を試してみて、

```
brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:

    autoconf
    cmake
    gauche
    gdbm
    git
    imagemagick
    jpeg
    libevent
    libtiff
    libtool
    libyaml
    node
    opencv
    pkg-config
    play
    python
    rbenv
    ruby-build
    scala
    tmux
    tree
    wget
```

```
meganii-air:~ meganii$ brew cleanup
Removing: /usr/local/Cellar/freetype/2.4.11...
Removing: /usr/local/Cellar/freetype/2.5.0.1...
Warning: Skipping git: most recent version 2.0.3 not installed
Warning: Skipping imagemagick: most recent version 6.8.9-5 not installed
Removing: /usr/local/Cellar/libpng/1.5.14...
Warning: Skipping (old) keg-only: /usr/local/Cellar/openssl/1.0.1e
Warning: Skipping (old) keg-only: /usr/local/Cellar/readline/6.2.4
Warning: Skipping ruby-build: most recent version 20140702 not installed
Removing: /Users/meganii/Library/Logs/Homebrew/autoconf...
Removing: /Users/meganii/Library/Logs/Homebrew/gauche...
Removing: /Users/meganii/Library/Logs/Homebrew/git...
Removing: /Users/meganii/Library/Logs/Homebrew/libevent...
Removing: /Users/meganii/Library/Logs/Homebrew/libtool...
Removing: /Users/meganii/Library/Logs/Homebrew/libyaml...
Removing: /Users/meganii/Library/Logs/Homebrew/node...
Removing: /Users/meganii/Library/Logs/Homebrew/opencv...
Removing: /Users/meganii/Library/Logs/Homebrew/openssl...
Removing: /Users/meganii/Library/Logs/Homebrew/python...
Removing: /Users/meganii/Library/Logs/Homebrew/readline...
Removing: /Users/meganii/Library/Logs/Homebrew/ruby-build...
Removing: /Users/meganii/Library/Logs/Homebrew/tmux...
Removing: /Users/meganii/Library/Logs/Homebrew/tree...
Removing: /Users/meganii/Library/Logs/Homebrew/wget...
```


`brew info`で見てみると、複数のバージョンが存在するみたい。

```
meganii-air:~ meganii$ brew info git
git: stable 2.0.3 (bottled), HEAD
http://git-scm.com
/usr/local/Cellar/git/1.8.3.1 (1324 files, 28M)
  Built from source
/usr/local/Cellar/git/1.8.4.3 (1343 files, 30M)
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/git.rb
```

`brew swich`で一つずつ使用するバージョン(最新バージョン)を指定していく


```
brew list | xargs brew unlink
Unlinking /usr/local/Cellar/autoconf/2.69... 0 symlinks removed
Unlinking /usr/local/Cellar/cmake/3.0.0... 0 symlinks removed
Unlinking /usr/local/Cellar/freetype/2.5.3_1... 9 symlinks removed
Unlinking /usr/local/Cellar/gauche/0.9.3.3... 0 symlinks removed
Unlinking /usr/local/Cellar/gdbm/1.11... 0 symlinks removed
Unlinking /usr/local/Cellar/git/1.8.4.3... 234 symlinks removed
Unlinking /usr/local/Cellar/imagemagick/6.8.7-0... 73 symlinks removed
Unlinking /usr/local/Cellar/jpeg/8d... 0 symlinks removed
Unlinking /usr/local/Cellar/libevent/2.0.21... 0 symlinks removed
Unlinking /usr/local/Cellar/libpng/1.6.12... 22 symlinks removed
Unlinking /usr/local/Cellar/libtiff/4.0.3... 0 symlinks removed
Unlinking /usr/local/Cellar/libtool/2.4.2... 0 symlinks removed
Unlinking /usr/local/Cellar/libyaml/0.1.4... 0 symlinks removed
Unlinking /usr/local/Cellar/node/0.10.22... 0 symlinks removed
Unlinking /usr/local/Cellar/opencv/2.4.9... 0 symlinks removed
Unlinking /usr/local/Cellar/openssl/1.0.1h... 0 symlinks removed
Unlinking /usr/local/Cellar/pkg-config/0.28... 0 symlinks removed
Unlinking /usr/local/Cellar/play/2.2.1... 0 symlinks removed
Unlinking /usr/local/Cellar/python/2.7.7_2... 0 symlinks removed
Unlinking /usr/local/Cellar/rbenv/0.4.0... 0 symlinks removed
Unlinking /usr/local/Cellar/readline/6.3.6... 0 symlinks removed
Unlinking /usr/local/Cellar/ruby-build/20131122.1... 4 symlinks removed
Unlinking /usr/local/Cellar/scala/2.10.3... 0 symlinks removed
Unlinking /usr/local/Cellar/sqlite/3.8.5... 0 symlinks removed
Unlinking /usr/local/Cellar/tmux/1.8... 0 symlinks removed
Unlinking /usr/local/Cellar/tree/1.6.0... 0 symlinks removed
Unlinking /usr/local/Cellar/wget/1.14... 0 symlinks removed
```

```
brew list | xargs brew link
Linking /usr/local/Cellar/autoconf/2.69... 18 symlinks created
Linking /usr/local/Cellar/cmake/3.0.0... 8 symlinks created
Linking /usr/local/Cellar/freetype/2.5.3_1... 8 symlinks created
Linking /usr/local/Cellar/gauche/0.9.3.3... 33 symlinks created
Linking /usr/local/Cellar/gdbm/1.11... 11 symlinks created
Linking /usr/local/Cellar/git/1.8.4.3... 219 symlinks created
Linking /usr/local/Cellar/imagemagick/6.8.7-0... 71 symlinks created
Linking /usr/local/Cellar/jpeg/8d... 17 symlinks created
Linking /usr/local/Cellar/libevent/2.0.21... 25 symlinks created
Linking /usr/local/Cellar/libpng/1.6.12... 18 symlinks created
Linking /usr/local/Cellar/libtiff/4.0.3... 106 symlinks created
Linking /usr/local/Cellar/libtool/2.4.2... 17 symlinks created
Linking /usr/local/Cellar/libyaml/0.1.4... 5 symlinks created
Linking /usr/local/Cellar/node/0.10.22... 1202 symlinks created
Linking /usr/local/Cellar/opencv/2.4.9... 65 symlinks created
Warning: openssl is keg-only and must be linked with --force
Note that doing so can interfere with building software.
Linking /usr/local/Cellar/pkg-config/0.28... 4 symlinks created
Linking /usr/local/Cellar/play/2.2.1... 1 symlinks created
Linking /usr/local/Cellar/python/2.7.7_2... 35 symlinks created
Linking /usr/local/Cellar/rbenv/0.4.0... 2 symlinks created
Warning: readline is keg-only and must be linked with --force
Note that doing so can interfere with building software.
Linking /usr/local/Cellar/ruby-build/20131122.1... 4 symlinks created
Linking /usr/local/Cellar/scala/2.10.3... 12 symlinks created
Warning: sqlite is keg-only and must be linked with --force
Note that doing so can interfere with building software.
Linking /usr/local/Cellar/tmux/1.8... 3 symlinks created
Linking /usr/local/Cellar/tree/1.6.0... 2 symlinks created
Linking /usr/local/Cellar/wget/1.14... 2 symlinks created
```

```
brew link openssl --force
brew link readline --force
brew link sqlite --force
```

## 参考
[brewでエラーimagemagick has multiple installed versions](http://banker0507.blogspot.jp/2013/04/homebrewimagemagick-has-multiple.html)
[Bureimono stdio.h: OS X Mavericks にアップデートしたら brew でいれた諸々へパスがおかしくなった](http://satorumpen.blogspot.jp/2014/03/os-x-mavericks-brew.html)
[Mavericks上書きアップデート - 皮肉な日々と心意気(2014-05-23)](http://www.snest.net/diary/20140523.html#p01)
[MarvericksにアップグレードしたらHomebrewのリンクが消えた — Masu_mi's blog](http://blog.masu-mi.me/2014/06/22/update_to_marvericks_cause_delete_link_of_homebrew.html)
[Mountain Lion から Mavericks にアップデートしたら Homebrew の諸々の Link が消えた - ravelllの日記](http://ravelll.hatenadiary.jp/entry/2014/04/13/210859)
[Mavericksアップグレードの際 Railsアプリケーションを頑張って起動させるまで - Qiita](http://qiita.com/tkwn1/items/ff613b08bdac1654ffe7)