1

我有 rails 2.3.8 应用程序我的 gemfile 中有 pg 但部署后显示错误

servers: ["apphost"]
    [apphost] executing command
 ** [out :: apphost] Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
 ** [out :: apphost] 
 ** [out :: apphost] /usr/local/bin/ruby extconf.rb
 ** [out :: apphost] checking for pg_config... no
 ** [out :: apphost] No pg_config... trying anyway. If building fails, please try again with
 ** [out :: apphost] --with-pg-config=/path/to/pg_config
 ** [out :: apphost] checking for libpq-fe.h... no
 ** [out :: apphost] Can't find the 'libpq-fe.h header
 ** [out :: apphost] *** extconf.rb failed ***
 ** [out :: apphost] Could not create Makefile due to some reason, probably lack of
 ** [out :: apphost] necessary libraries and/or headers.  Check the mkmf.log file for more
 ** [out :: apphost] details.  You may need configuration options.
 ** [out :: apphost] 
 ** [out :: apphost] Provided configuration options:
4

2 回答 2

3

您缺少在 gem 中编译 C 代码所需的 postgres 头文件。

如果您使用的是像 gentoo 这样的基于源代码的发行版,那么安装 postgresql 包就足够了。

如果你在一个类似 debian 的系统上,它们传统上不包括头文件和库,你必须安装相应的*-dev包。在你的情况下,在 ubuntu 上,它是libpq-dev

sudo apt-get install libpq-dev
于 2013-09-19T08:15:59.730 回答
2

通过解析日志,Gem 找不到 pg-config,要么 postgres 尚未安装在该服务器上,要么您需要正确配置路径。

于 2013-09-19T07:57:10.227 回答