无法安装pg gem,检查-lpq中的PQconnectdb()...否

use*_*439 8 postgresql ruby-on-rails pg rails-postgresql

我正在尝试使用PostgreSQL本地开发Ruby on Rails,所以我正在尝试安装pg gem.在Ubuntu 12.04上.在终端,我输入:

gem install pg -v '0.12.2'
Run Code Online (Sandbox Code Playgroud)

这会引发以下错误:

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

        /home/troyshu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby 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
    --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/troyshu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
    --with-pg
    --without-pg
    --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-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


Gem files will remain installed in /home/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1 for inspection.
Results logged to /home/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1/ext/gem_make.out
Run Code Online (Sandbox Code Playgroud)

有趣的是,在命令中添加sudo可以:

$ sudo gem install pg -v '0.12.2'
Building native extensions.  This could take a while...
Successfully installed pg-0.12.2
1 gem installed
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我必须运行"sudo apt-get install ruby​​1.9.1-dev"才能使上述命令生效.但我仍然无法进行任何开发,因为"捆绑安装"不起作用(并一直告诉我运行'gem install pg -v'0.12.2')

我有一种感觉"宝石安装pg"正在被绊倒

checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Run Code Online (Sandbox Code Playgroud)

但是,作为Ubuntu和RoR的完整菜鸟,我不知道为什么.也许我的搜索技巧也很糟糕,因为我无法找到解决我特定情况的方法.希望有一个修复?

谢谢!

thi*_*ler -2

当你这样做时,sudo gem install pggem 会安装在安装 ruby​​ 和 postgresql 的地方;当您这样做时,gem install pggem 会安装在您的主目录中(请参阅您的消息!)。sudo bundle install blah-blah-blah因此,考虑到您在本地工作的方式,您需要对所有宝石进行处理。当然,还有其他选项,例如 RVM,我不使用它。