我有 2 个 Ruby 版本: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:\Program Files (x86)\PostgreSQL\8.3\bin 添加到我的 PATH 中。
最佳答案
您收到的消息清楚地表明您缺少正确安装该 gem 所需的东西:
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.
昨天发布的最新版 pg (0.10.0) 没有 Windows native 版本,但如果您安装 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
关于ruby-on-rails - 无法在 Windows 上安装 pg gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4335750/