Atom に term2 パッケージを入れようとしたら Command Line Tools が入っていなくてコケた話


## 概要
Atom でターミナルが使えるように term2 パッケージを入れるときに Command Line Tools が入っていないことが原因でエラーを吐いていた。Command Line Tools を入れるとパッケージを入れることができた。

## 実行環境
```
$ apm -v
apm 0.116.0
npm 1.4.4
node 0.10.33
python 2.7.8
git 1.9.3
```

## `apm install term2` （初回実行時）
```
$ apm install term2
Installing term2 to /Users/misaki/.atom/packages ✗

> pty.js@0.2.4 install /private/var/folders/82/cv5yygps41v9803k6ysnj8br0000gp/T/apm-install-dir-11508-29717-1wfhwvt/node_modules/term2/node_modules/pty.js
> node-gyp rebuild

CXX(target) Release/obj.target/pty/src/unix/pty.o

npm http GET https://registry.npmjs.org/debounce/0.0.3
npm http GET https://registry.npmjs.org/fs-plus
npm http GET https://registry.npmjs.org/keypather
npm http GET https://registry.npmjs.org/atom-term.js/0.0.55
npm http GET https://github.com/chjj/pty.js/archive/master.tar.gz
npm http 304 https://registry.npmjs.org/fs-plus
npm http 304 https://registry.npmjs.org/atom-term.js/0.0.55
npm http 304 https://registry.npmjs.org/debounce/0.0.3
npm http 304 https://registry.npmjs.org/keypather
npm http 200 https://github.com/chjj/pty.js/archive/master.tar.gz
npm http GET https://registry.npmjs.org/underscore-plus
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/extend
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/rimraf
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/extend
../src/unix/pty.cc:37:10: fatal error: '/usr/include/util.h' file not found
#include </usr/include/util.h>
^
1 error generated.
make: *** [Release/obj.target/pty/src/unix/pty.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Applications/Atom.app/Contents/Resources/app/apm/node_modules/atom-package-manager/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Darwin 14.0.0
gyp ERR! command "node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/atom-package-manager/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /private/var/folders/82/cv5yygps41v9803k6ysnj8br0000gp/T/apm-install-dir-11508-29717-1wfhwvt/node_modules/term2/node_modules/pty.js
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm http 304 https://registry.npmjs.org/underscore-plus
npm http GET https://registry.npmjs.org/underscore
npm http 304 https://registry.npmjs.org/underscore
npm ERR! pty.js@0.2.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pty.js@0.2.4 install script.
npm ERR! This is most likely a problem with the pty.js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls pty.js
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 14.0.0
npm ERR! command "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/atom-package-manager/bin/node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/atom-package-manager/node_modules/npm/bin/npm-cli.js" "--globalconfig" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/atom-package-manager/.apmrc" "--userconfig" "/Users/misaki/.atom/.apmrc" "install" "/Users/misaki/.atom/.node-gyp/.atom/.apm/term2/0.9.4/package.tgz" "--target=0.18.0" "--arch=x64"
npm ERR! cwd /private/var/folders/82/cv5yygps41v9803k6ysnj8br0000gp/T/apm-install-dir-11508-29717-1wfhwvt
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.4
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/82/cv5yygps41v9803k6ysnj8br0000gp/T/apm-install-dir-11508-29717-1wfhwvt/npm-debug.log
npm ERR! not ok code 0
```

## `../src/unix/pty.cc:37:10: fatal error: '/usr/include/util.h' file not found` が初めのエラーなので調べる
似たエラーを出している方を発見。

- https://github.com/atom/terminal/issues/28

上記の URL のページをみると、Xcode の Command Line Tools が入っていないのが原因なのかもしれないと思い、`xcode-select --install` をしてみる。

## `xcode-select --install` の後に、もう一度 term2 パッケージを入れてみるとインストール成功
```
$ xcode-select --install
xcode-select: note: install requested for command line developer tools
```
```
$ apm install term2
Installing term2 to /Users/misaki/.atom/packages ✓
```