【问题标题】:unable to install gem pg - Can't find the PostgreSQL client library (libpq) [duplicate]无法安装 gem pg - 找不到 PostgreSQL 客户端库 (libpq) [重复]
【发布时间】:2015-01-30 21:44:29
【问题描述】:

在 ubuntu 14.04 中我无法安装 pg gem,但我也安装了 libpg-dev。

sudo apt-get install libpq-dev

Here我可以看到其他人也有同样的问题。

gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /home/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -r ./siteconf20141202-24533-1xrmav0.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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=/home/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --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
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib

extconf failed, exit code 1

Gem files will remain installed in /home/user/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.17.1 for inspection.
Results logged to /home/user/.rvm/gems/ruby-1.9.3-p194/extensions/x86_64-linux/1.9.1/pg-0.17.1/gem_make.out

有什么帮助吗?

【问题讨论】:

  • 奇怪的问题...我不知道,但是试试 ruby​​ sudo ldconfig,然后再试一次
  • 是的,还是一样。
  • dpkg -S /usr/lib/libpq.so 的输出是什么?
  • dpkg -S /usr/lib/libpq.so 返回libpq-dev: /usr/lib/libpq.so
  • 你可以sudo grep PQconnectdb /usr/lib/libpq.so吗?

标签: ruby-on-rails ruby postgresql ubuntu


【解决方案1】:

运行此代码sudo ARCHFLAGS="-arch x86_64" gem install pg -v '0.18.2',然后运行bundle install。它应该正确安装 pg gem。

【讨论】:

    【解决方案2】:

    您应该在线发布您的 mkmf.log 文件,但您还需要检查您的 Ruby 和 PostgreSQL 是否使用相同的 OpenSSL 版本。

    您可能已经通过 RVM 安装了 Ruby 和 OpenSSL,而您的 PostgreSQL 正在使用系统的版本。这会导致冲突。

    【讨论】:

    • 这对我有用。我已经通过 linuxbrew 和 apt-get 安装了 OpenSSL。删除了我的 brew 版本并且它有效。谢谢!
    【解决方案3】:

    我的电脑也有同样的问题。我只是运行rvm get stable 来更新rvm,然后再运行一次bundle install。成功安装此 pg gem 后。

    【讨论】:

    • 还是一样的rvm -v : rvm 1.26.3 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
    【解决方案4】:

    我猜你已经正确安装了 Postgres。你有没有尝试过这样的大旗?

    env ARCHFLAGS="-arch x86_64" gem install pg
    

    【讨论】:

    • 是的,我已经试过了;它不工作。
    猜你喜欢
    • 2021-07-18
    • 2014-10-27
    • 2015-05-03
    • 2011-08-27
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    • 2015-03-16
    相关资源
    最近更新 更多