macにhomebrewを入れてgitを入れた

いろいろあってmac book airを買いました。
普段がUbuntuなので簡単に移行できるかと思ったものの、やはりそう甘くはなかったです。
macで試行錯誤したことを書こうかと思います。

さて、macにhomebrewとgitを入れようとして早速軽くつまづいたのでそれについて残しておこうかと思います。

homebrewのインストール

楽勝です。

/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

以上。

gitのインストール

以下コマンドでgitが入ります。

brew install git

エラーが。。。。

==> Downloading http://git-core.googlecode.com/files/git-1.7.11.1.tar.gz
######################################################################## 100.0%
==> make prefix=/usr/local/Cellar/git/1.7.11.1 CC=/usr/bin/xcrun clang CFLAGS=-O
GIT_VERSION = 1.7.11.1
    * new build flags or prefix
    * new link flags
./generate-cmdlist.sh > common-cmds.h+ && mv common-cmds.h+ common-cmds.h
/usr/bin/xcrun clang -o hex.o -c -MF ./.depend/hex.o.d -MMD -MP  -Os -w -pipe -march=native -Qunused-arguments -I. -DUSE_ST_TIMESPEC -DNO_GETTEXT  -DHAVE_DEV_TTY -DXDL_FAST_HASH -DSHA1_HEADER='<openssl/sha.h>'  -DNO_MEMMEM -DSHELL_PATH='"/bin/sh"'  hex.c
/usr/bin/xcrun clang -o ident.o -c -MF ./.depend/ident.o.d -MMD -MP  -Os -w -pipe -march=native -Qunused-arguments -I. -DUSE_ST_TIMESPEC -DNO_GETTEXT  -DHAVE_DEV_TTY -DXDL_FAST_HASH -DSHA1_HEADER='<openssl/sha.h>'  -DNO_MEMMEM -DSHELL_PATH='"/bin/sh"'  ident.c
/usr/bin/xcrun clang -o kwset.o -c -MF ./.depend/kwset.o.d -MMD -MP  -Os -w -pipe -march=native -Qunused-arguments -I. -DUSE_ST_TIMESPEC -DNO_GETTEXT  -DHAVE_DEV_TTY -DXDL_FAST_HASH -DSHA1_HEADER='<openssl/sha.h>'  -DNO_MEMMEM -DSHELL_PATH='"/bin/sh"'  kwset.c
In file included from ident.c:8:
In file included from kwset.c:37:
In file included from In file included from ./cache.h:4:
./git-compat-util.h./cache.h::93:10In file included from hex.c:1::
In file included from ./cache.h4 :
:./git-compat-util.h4:
./git-compat-util.h:fatal error: 'unistd.h' file not found
93:10: fatal error: 'unistd.h' file not found
:93:10: fatal error: 'unistd.h' file not found
#include <unistd.h>
#include <unistd.h>         ^

         ^
#include <unistd.h>
         ^
/usr/bin/xcrun clang -o levenshtein.o -c -MF ./.depend/levenshtein.o.d -MMD -MP  -Os -w -pipe -march=native -Qunused-arguments -I. -DUSE_ST_TIMESPEC -DNO_GETTEXT  -DHAVE_DEV_TTY -DXDL_FAST_HASH -DSHA1_HEADER='<openssl/sha.h>'  -DNO_MEMMEM -DSHELL_PATH='"/bin/sh"'  levenshtein.c
1 error generated.
1 error generated.
make: *** [hex.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [ident.o] Error 1
In file included from levenshtein.c:1:
In file included from ./cache.h:4:
./git-compat-util.h:93:10: fatal error: 'unistd.h' file not found
#include <unistd.h>
         ^
1 error generated.
make: *** [kwset.o] Error 1
1 error generated.
make: *** [levenshtein.o] Error 1
==> Build Environment
CPU: quad-core 64-bit dunno
MacOS: 10.7.4-x86_64
Xcode: 4.3.3
CC: /usr/bin/xcrun clang => /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang

CXX: /usr/bin/xcrun clang++ => /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++

LD: /usr/bin/xcrun clang => /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang

CFLAGS: -Os -w -pipe -march=native -Qunused-arguments
CXXFLAGS: -Os -w -pipe -march=native -Qunused-arguments
MAKEFLAGS: -j4
Error: Failed executing: make prefix=/usr/local/Cellar/git/1.7.11.1 CC=/usr/bin/xcrun\ clang CFLAGS=-Os\ -w\ -pipe\ -march=native\ -Qunused-arguments LDFLAGS= install (git.rb:49)
These existing issues may help you:
    https://github.com/mxcl/homebrew/issues/8643
    https://github.com/mxcl/homebrew/issues/9618
    https://github.com/mxcl/homebrew/issues/10544
    https://github.com/mxcl/homebrew/issues/11481
    https://github.com/mxcl/homebrew/issues/12344
    https://github.com/mxcl/homebrew/issues/12814
    https://github.com/mxcl/homebrew/issues/12897
Otherwise, please report the bug:
    https://github.com/mxcl/homebrew/wiki/reporting-bugs

この場合、Xcodeをインストール・起動し、
[Xcode] - [preference] - [Downloads]からCommand Line Toolsをインストールし、再度gitをインストールします。