小编典典

无法在 Windows 上安装 pg gem

javascript

我有 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 中。


阅读 255

收藏
2022-05-23

共1个答案

小编典典

您收到的消息清楚地表明您缺少正确安装该 gem 的东西:

由于某种原因无法创建 Makefile,可能缺少必要的库和/或头文件。检查 mkmf.log 文件以获取更多详细信息。您可能需要配置选项。

昨天发布的最新版本 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
2022-05-23