gem で pg をインストール

Windows 環境のころは PostgreSQL 用ドライバとして使ってた pg 。とりあえず、昔にお試し作りしたのを動かしてみようと rvm で 1.8.6 にスイッチしてインストールしてみたら ruby 1.8.7 以降での対応になってた。まぁ、仕方ないよね。

$ gem install pg
ERROR: Error installing pg:
pg requires Ruby version >= 1.8.7.


http://rubygems.org:RubyGems.org を見ると最新の pg は 0.11.0 。0.10.0 から ruby 1.8.7 になってるっぽい。

気を取り直して 0.9.0 を実行 ... してみたら失敗 orz。なんで?

$ gem install pg -v 0.9.0
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
...
checking for pg_config... no

=========== WARNING ===========

You are building this extension on OS X without setting the
ARCHFLAGS environment variable, and pg_config wasn't found in
your PATH. If you are seeing this message, that means that the
build will probably fail.

If it does, you can correct this by either including the path
to 'pg_config' in your PATH or setting the environment variable
ARCHFLAGS to '-arch ' before building.

For example:
(in bash) $ export PATH=/opt/local/lib/postgresql84/bin:$PATH
$ export ARCHFLAGS='-arch x86_64'
...


pg_config が PATH に見つからないって。確かに入れてない。

$ export PATH=/opt/local/lib/postgresql83/bin:$PATH
$ pg install pg -v 0.9.0

おし、今度こそ OK :-)