Windowsに ソースコード検索エンジン「Milkode」をインストールする

「[数万のソースコードから目的の一行を一瞬で見つけ出す、Milkode](http://d.hatena.ne.jp/tuto0621/20110730/1312040692) 」、大変便利です！！
作者の ongaeshi さん、素敵！！

Mac だと、さくっとインストールできるのですが、
__Windows にインストールする際に、かなりつまづいた__ので、結論だけメモ。

# Ruby のインストール

ActiveRuby 1.8.7 では、Milkodeを動かすのに手間取ったので、これを機に
RubyInstaller (Ruby 1.9.3-p0) に入れ替えてみました。

## Ruby 1.9.3-p0 のインストール

__Ruby 1.9.3-p194 だと、`milk init` コマンド実行時にsegmentation faultが発生する__ので Ruby 1.9.3-p0 を入れます。

1. [RubyInstaller for Windows](http://rubyinstaller.org/) のサイトにアクセス
2. Download → Archives → __Ruby 1.9.3-p0__ をクリックしてダウンロード
3. インストーラの指示に従ってインストールする

## DevKit のインストール

Milkode インスール時のビルドに必要になるので。

1. [RubyInstaller for Windows](http://rubyinstaller.org/) のサイトにアクセス
2. Download → DEVELOPMENT KIT をダウンロードする
3. 適当な場所に展開する。 (C:\DevKit に展開したものとして話を進めます)

# Milkode のインストール

ビルド環境が整ったコマンドプロンプトを起動し、そこから Milkodeインストール手順に従ってコマンド実行します。

1. `c:\DevKit\msys.bat` を実行します。コマンドプロンプトが開くので、Milkode公式サイト「[Milkode ダウンロード](http://milkode.ongaeshi.me/wiki/%E3%83%A1%E3%82%A4%E3%83%B3%E3%83%9A%E3%83%BC%E3%82%B8)」
のインストール手順に従ってコマンドを打ち込んでいきます。

```bat
> gem install eventmachine --pre
> gem install milkode --platform ruby
```

特に問題なくインストール完了します。

# Milkode を使う

詳しい使い方は[マニュアル](http://milkode.ongaeshi.me/wiki/%E3%83%9E%E3%83%8B%E3%83%A5%E3%82%A2%E3%83%AB)を参考にして下さい。

## データベースの初期化

```bat
> milk init --default
```

## 検索対象のソースコードの追加

```bat
> milk add [ソースコードのあるディレクトリ]
```

## ブラウザから検索

```bat
> milk web
```

![Milkode Web検索画面](https://lh4.googleusercontent.com/-2mB1sYPkio0/T7c3DfNPI1I/AAAAAAAAEGc/XHyIvybsqas/s640/2012-05-19%252015h00_18.jpg)

ソースコード内をちょっぱやで検索できて超便利！！
これで、いままでに書いたソースコードをどこかにやってしまう自分とおさらばしたい！

VIMから利用できるようにしたいな・・・。


# 参考：インストール時のログ
```bat
$ gem install eventmachine --pre
Fetching: eventmachine-1.0.0.beta.4.1-x86-mingw32.gem (100%)
Successfully installed eventmachine-1.0.0.beta.4.1-x86-mingw32
1 gem installed
Installing ri documentation for eventmachine-1.0.0.beta.4.1-x86-mingw32...
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for docs/DocumentationGuidesIndex.md, skipping
unable to convert "\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for docs/GettingStarted.md, skipping
Installing RDoc documentation for eventmachine-1.0.0.beta.4.1-x86-mingw32...
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for docs/DocumentationGuidesIndex.md, skipping
unable to convert "\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for docs/GettingStarted.md, skipping

$ gem install milkode --platform ruby
Fetching: highline-1.6.12.gem (100%)
Fetching: termcolor-1.2.1.gem (100%)
Fetching: pkg-config-1.1.3.gem (100%)
Fetching: io-like-0.3.0.gem (100%)
Fetching: archive-zip-0.5.0.gem (100%)
Fetching: rroonga-2.0.4.gem (100%)
Building native extensions.  This could take a while...
Fetching: rack-1.4.1.gem (100%)
Fetching: rack-protection-1.2.0.gem (100%)
Fetching: tilt-1.3.3.gem (100%)
Fetching: sinatra-1.3.2.gem (100%)
Fetching: addressable-2.2.8.gem (100%)
Fetching: launchy-2.1.0.gem (100%)
Fetching: coderay-1.0.6.gem (100%)
Fetching: daemons-1.1.8.gem (100%)
Fetching: thin-1.3.1.gem (100%)
Building native extensions.  This could take a while...
Fetching: haml-3.1.6.gem (100%)
Fetching: sass-3.1.18.gem (100%)
Fetching: thor-0.15.2.gem (100%)
Fetching: milkode-0.7.1.gem (100%)
Successfully installed highline-1.6.12
Successfully installed termcolor-1.2.1
Successfully installed pkg-config-1.1.3
Successfully installed io-like-0.3.0
Successfully installed archive-zip-0.5.0
Successfully installed rroonga-2.0.4
Successfully installed rack-1.4.1
Successfully installed rack-protection-1.2.0
Successfully installed tilt-1.3.3
Successfully installed sinatra-1.3.2
Successfully installed addressable-2.2.8
Successfully installed launchy-2.1.0
Successfully installed coderay-1.0.6
Successfully installed daemons-1.1.8
Successfully installed thin-1.3.1
Successfully installed haml-3.1.6
Successfully installed sass-3.1.18
Successfully installed thor-0.15.2
Successfully installed milkode-0.7.1
19 gems installed
Installing ri documentation for highline-1.6.12...
Installing ri documentation for termcolor-1.2.1...
Installing ri documentation for pkg-config-1.1.3...
Installing ri documentation for io-like-0.3.0...
Installing ri documentation for archive-zip-0.5.0...
Installing ri documentation for rroonga-2.0.4...
Installing ri documentation for rack-1.4.1...
Installing ri documentation for rack-protection-1.2.0...
Installing ri documentation for tilt-1.3.3...
Installing ri documentation for sinatra-1.3.2...
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.de.rdoc, skipping
unable to convert U+00E0 from UTF-8 to Windows-31J for README.fr.rdoc, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.hu.rdoc, skipping
unable to convert "\xE6" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.jp.rdoc, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.pt-br.rdoc, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.pt-pt.rdoc, skipping
unable to convert "\xD0" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.ru.rdoc, skipping
unable to convert "\xE6" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.zh.rdoc, skipping
Installing ri documentation for addressable-2.2.8...
unable to convert U+2014 from UTF-8 to Windows-31J for lib/addressable/uri.rb, s
kipping
Installing ri documentation for launchy-2.1.0...
Installing ri documentation for coderay-1.0.6...
Installing ri documentation for daemons-1.1.8...
Installing ri documentation for thin-1.3.1...
Installing ri documentation for haml-3.1.6...
Installing ri documentation for sass-3.1.18...
Installing ri documentation for thor-0.15.2...
Installing ri documentation for milkode-0.7.1...
Installing RDoc documentation for highline-1.6.12...
Installing RDoc documentation for termcolor-1.2.1...
Installing RDoc documentation for pkg-config-1.1.3...
Installing RDoc documentation for io-like-0.3.0...
Installing RDoc documentation for archive-zip-0.5.0...
Installing RDoc documentation for rroonga-2.0.4...
Installing RDoc documentation for rack-1.4.1...
Installing RDoc documentation for rack-protection-1.2.0...
Installing RDoc documentation for tilt-1.3.3...
Installing RDoc documentation for sinatra-1.3.2...
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.de.rdoc, skipping
unable to convert U+00E0 from UTF-8 to Windows-31J for README.fr.rdoc, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.hu.rdoc, skipping
unable to convert "\xE6" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.jp.rdoc, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.pt-br.rdoc, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.pt-pt.rdoc, skipping
unable to convert "\xD0" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.ru.rdoc, skipping
unable to convert "\xE6" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for README.zh.rdoc, skipping
Installing RDoc documentation for addressable-2.2.8...
unable to convert U+2014 from UTF-8 to Windows-31J for lib/addressable/uri.rb, s
kipping
Installing RDoc documentation for launchy-2.1.0...
Installing RDoc documentation for coderay-1.0.6...
Installing RDoc documentation for daemons-1.1.8...
Installing RDoc documentation for thin-1.3.1...
Installing RDoc documentation for haml-3.1.6...
Installing RDoc documentation for sass-3.1.18...
Installing RDoc documentation for thor-0.15.2...
Installing RDoc documentation for milkode-0.7.1...

$
```

(Milkode は現時点でバージョン 0.7.1)