通过capistrano部署安装pg时出错

时间:2013-09-19 07:40:51

标签: ruby-on-rails ruby postgresql capistrano

我有导轨2.3.8 app 我在我的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:

2 个答案:

答案 0 :(得分:3)

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

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

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

sudo apt-get install libpq-dev

答案 1 :(得分:2)

从解析日志中,Gem无法找到pg-config,或者还没有在该服务器上安装postgres,或者您需要正确配置路径。