ruby-on-rails - 无法在 Windows 上安装 pg gem

标签 ruby-on-rails ruby windows postgresql gem

我有 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/

相关文章:

mysql - 事件记录 - destroy_all 并在事务中创建

ruby-on-rails - 正在尝试安装 libv8, "failed to build gem native extension"

ruby - 将 savon 与 exacttarget 的 Web 服务结合使用

windows - 安装 Windows 8 SDK 时出错

c - 实现 Com 端口终端的最简单方法。 ( Windows ,C)

ruby-on-rails - "Nil location provided. Can' t build URI."在 rails 中执行 AJAX 请求时是什么意思?

php - 如何将 Python 卖给客户/老板/个人

ruby - Ruby 中的加载错误

windows - 远程执行时短 LdrLoadDll stub 崩溃

ruby-on-rails - 如何在 Rails 之外使用 Rails 日期辅助方法?