HomeBrewでMacの環境構築 (追記@2016/1/8: 古くなってたのでbrew bundleを使うやり方に更新)

きっかけ

BoxenはPuppetfileの書き方覚えないといけなかったり、一人で使うには結構面倒らしい。 以下のページを参考。

確かにhomebrew-caskとかを使ったほうがシンプルで自分に向いてそう。

やったこと (追記@2016/1/8: これより下は結構変わっていたので更新)

GitHub - Homebrew/homebrew-bundle: Bundler for non-Ruby dependencies from Homebrew を使う。

XCodeまわり

$ sudo xcodebuild -license
$ xcode-select --install

Homebrewをインストール

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew doctor
$ brew update
$ brew tap Homebrew/bundle

brew bundleによるインストール

移行前のPCで $ brew bundle dump してできたBrewfileを新しい環境に持ってきて、 brew bundle$ brew bundle dump の結果は以下のようになった。

tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
brew "aspell"
brew "autoconf"
brew "autoconf-archive"
brew "automake"
brew "boost"
brew "gettext"
brew "cairo"
brew "ccache"
brew "cmake"
brew "dep"
brew "direnv"
brew "dnsmasq"
brew "jpeg"
brew "xz"
brew "ffmpeg", args: ["with-fdk-aac", "with-freetype", "with-libass", "with-webp"]
brew "gcc"
brew "gdb"
brew "git"
brew "gnu-sed"
brew "readline"
brew "sqlite"
brew "gobject-introspection"
brew "graphite2"
brew "graphviz"
brew "gtk-doc"
brew "hexedit"
brew "htop"
brew "imagemagick", args: ["with-fontconfig", "with-librsvg", "with-libwmf"]
brew "jq"
brew "llvm@6"
brew "lua"
brew "luarocks"
brew "mongodb"
brew "mysql"
brew "nasm"
brew "ninja"
brew "node"
brew "pandoc"
brew "peco"
brew "portaudio"
brew "portmidi"
brew "postgresql"
brew "pyenv"
brew "ruby-build"
brew "rbenv"
brew "redis"
brew "rmtrash"
brew "ruby", link: true
brew "rust"
brew "thrift"
brew "tmux"
brew "tree"
brew "wget"
brew "yasm"

以前はdotfilesでBrewfileを管理していたんですが、やめた。毎回必要になったらbrew bundle dumpする。

HomeBrewの普段使わないオプション

brew infobrew switch

$ brew info node
node: stable 6.2.0 (bottled), HEAD
Platform built on the V8 JavaScript runtime to build network applications
https://nodejs.org/
/usr/local/Cellar/node/5.0.0 (2,942 files, 28.7M)
  Poured from bottle on 2015-10-30 at 07:30:57
/usr/local/Cellar/node/5.4.0 (2,837 files, 34.4M)
  Poured from bottle on 2016-01-08 at 20:58:32
/usr/local/Cellar/node/5.6.0 (3,739 files, 35.5M)
  Poured from bottle on 2016-02-20 at 13:01:45
/usr/local/Cellar/node/5.10.1 (3,663 files, 35.7M) *
  Poured from bottle on 2016-04-16 at 14:04:32
/usr/local/Cellar/node/6.2.0 (3,979 files, 40.3M)
  Poured from bottle on 2016-05-27 at 11:23:27
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/node.rb
==> Dependencies
Build: xz ✔, pkg-config ✔
Optional: openssl ✔
==> Options
--with-debug
    Build with debugger hooks
--with-full-icu
    Build with full-icu (all locales) instead of small-icu (English only)
--with-openssl
    Build with openssl support
--without-completion
    npm bash completion will not be installed
--without-npm
    npm will not be installed
--HEAD
    Install HEAD version
==> Caveats
Please note by default only English locale support is provided. If you need
full locale support you should either rebuild with full icu:
  `brew reinstall node --with-full-icu`
or add full icu data at runtime following:
  https://github.com/nodejs/node/wiki/Intl#using-and-customizing-the-small-icu-build

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

切り替えるには

$ brew switch node 5.10.1
Cleaning /usr/local/Cellar/node/5.0.0
Cleaning /usr/local/Cellar/node/5.10.1
Cleaning /usr/local/Cellar/node/5.4.0
Cleaning /usr/local/Cellar/node/5.6.0
Cleaning /usr/local/Cellar/node/6.2.0
7 links created for /usr/local/Cellar/node/5.10.1
$ node --version
v5.10.1