Homebrewのエラーを治す


```lang:コンソール
$ brew doctor

```

いっぱいエラーがでた。


```lang:コンソール
Warning: /usr/local/lib/pkgconfig isn't writable.
This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a brew tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/lib/pkgconfig
xcrun: error: active developer path ("/Volumes/Xcode 4.5 DP4/Xcode45-DP4.app/Contents/Developer") does not exist, use xcode-select to change
xcrun: error: active developer path ("/Volumes/Xcode 4.5 DP4/Xcode45-DP4.app/Contents/Developer") does not exist, use xcode-select to change

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.

Unexpected dylibs:
    /usr/local/lib/libavcodec.54.91.100.dylib
    /usr/local/lib/libavdevice.54.3.102.dylib
    /usr/local/lib/libavfilter.3.34.101.dylib
    /usr/local/lib/libavformat.54.61.104.dylib
    /usr/local/lib/libavutil.52.17.100.dylib
    /usr/local/lib/libmp3lame.0.dylib
    /usr/local/lib/libswresample.0.17.102.dylib
    /usr/local/lib/libswscale.2.2.100.dylib

Warning: Unbrewed .la files 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.

Unexpected .la files:
    /usr/local/lib/libmp3lame.la

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
    /usr/local/lib/pkgconfig/fuse.pc
    /usr/local/lib/pkgconfig/libavcodec.pc
    /usr/local/lib/pkgconfig/libavdevice.pc
    /usr/local/lib/pkgconfig/libavfilter.pc
    /usr/local/lib/pkgconfig/libavformat.pc
    /usr/local/lib/pkgconfig/libavutil.pc
    /usr/local/lib/pkgconfig/libswresample.pc
    /usr/local/lib/pkgconfig/libswscale.pc
    /usr/local/lib/pkgconfig/nodejs.pc

Warning: Unbrewed static libraries 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.

Unexpected static libraries:
    /usr/local/lib/libavcodec.a
    /usr/local/lib/libavdevice.a
    /usr/local/lib/libavfilter.a
    /usr/local/lib/libavformat.a
    /usr/local/lib/libavutil.a
    /usr/local/lib/libmp3lame.a
    /usr/local/lib/libswresample.a
    /usr/local/lib/libswscale.a

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:

    node
    pcre
xcrun: error: active developer path ("/Volumes/Xcode 4.5 DP4/Xcode45-DP4.app/Contents/Developer") does not exist, use xcode-select to change
xcrun: error: active developer path ("/Volumes/Xcode 4.5 DP4/Xcode45-DP4.app/Contents/Developer") does not exist, use xcode-select to change

Warning: Missing git origin remote.

Without a correctly configured origin, Homebrew won't update
properly. You can solve this by adding the Homebrew remote:
  cd /usr/local
  git remote add origin https://github.com/Homebrew/homebrew.git
xcrun: error: active developer path ("/Volumes/Xcode 4.5 DP4/Xcode45-DP4.app/Contents/Developer") does not exist, use xcode-select to change

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

    dbilogstrip
    dbiprof
    dbiproxy

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
xcrun: error: active developer path ("/Volumes/Xcode 4.5 DP4/Xcode45-DP4.app/Contents/Developer") does not exist, use xcode-select to change

Warning: A newer Command Line Tools release is available
Update them from Software Update in the App Store.
xcrun: error: active developer path ("/Volumes/Xcode 4.5 DP4/Xcode45-DP4.app/Contents/Developer") does not exist, use xcode-select to change

```

## 権限エラー

修正する

```lang:コンソール
$ sudo chown {your-user-name} /usr/local/lib/pkgconfig
```

## 余分なファイルを消す

```lang:コンソール
$ rm -rf /usr/local/lib/libavcodec.54.91.100.dylib
$ rm -rf /usr/local/lib/libavdevice.54.3.102.dylib
$ rm -rf /usr/local/lib/libavfilter.3.34.101.dylib
$ rm -rf /usr/local/lib/libavformat.54.61.104.dylib
$ rm -rf /usr/local/lib/libavutil.52.17.100.dylib
$ rm -rf /usr/local/lib/libmp3lame.0.dylib
$ rm -rf /usr/local/lib/libswresample.0.17.102.dylib
$ rm -rf /usr/local/lib/libswscale.2.2.100.dylib


$ rm -rf /usr/local/lib/libmp3lame.la


$ rm -rf /usr/local/lib/pkgconfig/fuse.pc
$ rm -rf /usr/local/lib/pkgconfig/libavcodec.pc
$ rm -rf /usr/local/lib/pkgconfig/libavdevice.pc
$ rm -rf /usr/local/lib/pkgconfig/libavfilter.pc
$ rm -rf /usr/local/lib/pkgconfig/libavformat.pc
$ rm -rf /usr/local/lib/pkgconfig/libavutil.pc
$ rm -rf /usr/local/lib/pkgconfig/libswresample.pc
$ rm -rf /usr/local/lib/pkgconfig/libswscale.pc
$ rm -rf /usr/local/lib/pkgconfig/nodejs.pc


$ rm -rf /usr/local/lib/libavcodec.a
$ rm -rf /usr/local/lib/libavdevice.a
$ rm -rf /usr/local/lib/libavfilter.a
$ rm -rf /usr/local/lib/libavformat.a
$ rm -rf /usr/local/lib/libavutil.a
$ rm -rf /usr/local/lib/libmp3lame.a
$ rm -rf /usr/local/lib/libswresample.a
$ rm -rf /usr/local/lib/libswscale.a

```

## リンクの設定

```lang:コンソール
$ brew link node
$ brew link pcre

```

nodeがリンクできないなどのエラーがでたので削除して、再インストールした

```lang:コンソール
$ sudo brew uninstall node.js
$ brew install node
```

こんなエラーがでたので

```lang:コンソール
$ Target /usr/local/lib/dtrace/node.d already exists. You may need to delete it.
```

これ

```lang:コンソール
$ brew link --overwrite node

```

さらに

```lang:コンソール
$ Error: Permission denied - /usr/local/lib/dtrace/node.d
```

これ

[Error: The 'brew link' step did not complete successfully](http://stackoverflow.com/questions/12607155/error-the-brew-link-step-did-not-complete-successfully)

node を消して、再インストール

```lang:コンソール
$ brew uninstall npm
$ brew uninstall node
$ npm uninstall npm -g
$ sudo rm -rf /usr/local/lib/node_module

$ sudo rm -rf /usr/local/include/node
$ sudo rm -rf /usr/local/lib/node

$ brew install node
```

で

```lang:コンソール
$ xcrun: error: active developer path ("/Volumes/Xcode 4.5 DP4/Xcode45-DP4.app/Contents/Developer") does not exist, use xcode-select to change
```

これ

```lang:コンソール
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
```
次

```lang:コンソール
$ Warning: /usr/bin occurs before /usr/local/bin
```

これ

```lang:コンソール
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
```

これのあとコンソール再起動　←　これにはまった

完


## 参考サイト

[Mountain Lion環境へのHomebrew & gitインストール手順](http://blog.pinkpinkpink.net/2012/07/homebrew.html)

[Mac OSX に Homebrew をインストールする](http://d.hatena.ne.jp/january/20130723/1374538421)