Techioz Blog

Windows に pg gem をインストールできない

概要

Ruby のバージョンは 2 つあります: 1.8.7 と 1.9.2、および PostgreSQL 8.3。いずれにも pg gem をインストールできません。このエラーが発生する:

C:/Development/Ruby187/bin/ruby.exe extconf.rb
checking for pg_config... yes
not recorded
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
 --with-opt-dir
 --without-opt-dir
 --with-opt-include
 --without-opt-include=${opt-dir}/include
 --with-opt-lib
 --without-opt-lib=${opt-dir}/lib
 --with-make-prog
 --without-make-prog
 --srcdir=.
 --curdir
 --ruby=C:/Development/Ruby187/bin/ruby
 --with-pg
 --without-pg
 --with-pg-config
 --without-pg-config
 --with-pg-dir
 --without-pg-dir
 --with-pg-include
 --without-pg-include=${pg-dir}/include
 --with-pg-lib
 --without-pg-lib=${pg-dir}/lib

よくある問題であることはわかっていますが、有効な解決策はまだ見つかりません… ああ、C:Files (x86)\8.3 を PATH に追加しました。

解決策

表示されているメッセージは、その gem を正しくインストールするには何かが不足していることを明確に示しています。

昨日リリースされた pg の最新リリース (0.10.0) には Windows ネイティブ バージョンはありませんが、0.9.0 をインストールするとバイナリが問題なくインストールされるはずです。

とにかく、gem をインストールしたい場合は、ビルド環境がインストールされている必要があります。 RubyInstaller を使用している場合は、DevKit が必要です

gem のインストールには、gem のインストールに追加のオプション (–with-pg-dir など) を指定することのみが必要です。

subst X: "C:\Program Files (x86)\PostgreSQL\8.3"
gem install pg -- --with-pg-dir=X:
subst X: /D