【问题标题】:Error installing pg through capistrano deployment通过 capistrano 部署安装 pg 时出错
【发布时间】:2013-09-19 07:40:50
【问题描述】:

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

【问题讨论】:

    标签: ruby-on-rails ruby postgresql capistrano


    【解决方案1】:

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

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

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

    sudo apt-get install libpq-dev
    

    【讨论】:

    • 服务器在 redhat.. 也安装了“yum install postgresql-devel”.. 仍然面临问题
    • This is what package installs。你能确认文件/usr/include/pgsql/server/libpq/libpq.h 存在吗?
    【解决方案2】:

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

    【讨论】:

    • which pg_config 在您的服务器上为您提供了什么?
    • /usr/pgsql-9.0/bin/pg_config
    • 那么您需要更改您的捆绑配置以使用该路径bundle config build.pg --with-pg-config=/usr/pgsql-9.0/bin/pg_config
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-02
    • 2017-05-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-16
    • 2014-01-16
    • 2016-01-24
    相关资源
    最近更新 更多