PG 1.0.0致命错误:未找到'libpq-fe.h'文件

17

安装pg(1.0.0)时出错,Bundler无法继续

我在使用bundle install时遇到问题,无法完成安装。

我该如何才能完成bundle安装?

  find_executable: checking for pg_config... -------------------- no

    --------------------

    find_header: checking for libpq-fe.h... -------------------- no

    "clang -o conftest -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0 -I. -I/Users/leotyndall/.rbenv/versions/2.4.2/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe conftest.c  -L. -L/Users/leotyndall/.rbenv/versions/2.4.2/lib -L. -L/Users/leotyndall/.rbenv/versions/2.4.2/lib  -fstack-protector -L/usr/local/lib     -lruby-static -framework CoreFoundation  -lpthread -ldl -lobjc "
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2: 
    3: int main(int argc, char **argv)
    4: {
    5:   return 0;
    6: }
    /* end */

        "clang -E -I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0/x86_64-darwin17 - 
             I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby- 
         2.4.0/ruby/backward - 
         I/Users/leotyndall/.rbenv/versions/2.4.2/include/ruby-2.4.0 -I. - 
         I/Users/leotyndall/.rbenv/versions/2.4.2/include  -D_XOPEN_SOURCE - 
         D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno- 
         error=shorten-64-to-32  -pipe  conftest.c -o conftest.i"
         conftest.c:3:10: fatal error: 'libpq-fe.h' file not found
         #include <libpq-fe.h>
             ^~~~~~~~~~~~
         1 error generated.
         checked program was:
         /* begin */
         1: #include "ruby.h"
         2: 
         3: #include <libpq-fe.h>
        /* end */

    --------------------


     extconf failed, exit code 1


        An error occurred while installing pg (1.0.0), and Bundler cannot continue.
        Make sure that `gem install pg -v '1.0.0'` succeeds before bundling.

尝试在您的Gemfile中使用较低版本的pg,例如pg -v '0.18'。 - Gaurav Gupta
可能是你的$PATH设置有问题。你能在终端中粘贴echo "${PATH//:/\n}"的输出吗?还有你的Gemfile文件吗? - lacostenycoder
将最具体的错误消息移到标题中。重新格式化以提高清晰度。将问题移到文本顶部并重新表述以提高清晰度。 - Andy
我曾经遇到过类似的问题,即找不到pg_config,这个解决方案解决了我的问题。 - BlackCoffee
4个回答

17

16

尝试安装 libpq-dev 或其等效软件包:

  • 对于Ubuntu系统: sudo apt-get install libpq-dev
  • 对于 Red Hat Linux (RHEL) 系统: yum install postgresql-devel
  • 对于Mac Homebrew: brew install postgresql
  • 对于Mac MacPorts PostgreSQL: gem install pg -- --with-pg-config=/opt/local/lib/postgresql[版本号]/bin/pg_config
  • 对于 OpenSuse: zypper in postgresql-devel

在OSX(HeighSierra)上,我找不到如何安装仅限postgres客户端的方法。因此,您必须安装postgresql(或使用brew简单地安装postgres),以获取所需的文件libpq-fe.h。 - JL M

5
我通过安装库来解决这个问题:
``` brew install libpqxx ```
接下来,正常安装pg...你可以使用gem
``` gem install pg ```

3
brew install libpq

gem install pg -v '1.2.3' --source 'https://rubygems.org/' -- --with-pg-config=/opt/homebrew/Cellar/libpq/13.2/bin/pg_config

我的本地路径有点不同:/usr/local/opt/libpq/bin/pg_config,但除此之外一切都很顺利。在Big Sur上。 - marc_alain

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接