无法在Ubuntu 12.10(AMD64)上安装gem“pg”

3

我一直在尝试在我的ruby 1.9.3-p286上安装"pg"宝石,但似乎没有任何作用。

我已经安装了postgresql(9.1)、libpq-dev和其他一些像postgresql-server-dev-9.1这样的软件包。我尝试通过传递“with-pg-config”标志来安装gem,但仍然没有任何作用。

每次我尝试安装gem时,都会输出类似于以下内容:

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

        /home/lynux/.rvm/rubies/ruby-1.9.3-p286/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/lynux/.rvm/rubies/ruby-1.9.3-p286/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/lynux/.rvm/gems/ruby-1.9.3-p286@phisiodata/gems/pg-0.14.1 for inspection.
Results logged to /home/lynux/.rvm/gems/ruby-1.9.3-p286@phisiodata/gems/pg-0.14.1/ext/gem_make.out

我做错了什么?在尝试安装宝石之前,我是否应该做些其他事情?

提前致谢。

[编辑]

好的,所以joelparkerhenderson的答案让我想到可能存在路径和库方面的问题,然后我继续深入挖掘...

我找到了this 一篇很棒的文章,解决了问题!问题基本上出在RVM上。所以,我的问题已经解决了,对于任何可能遭受同样问题的人,请点击链接!

1个回答

2

你的错误看起来像是缺少了libpq-dev

你是否准备先在系统上安装Postgres?

尝试这样做:

sudo apt-get install postgresql postgresql-client postgresql-server-dev-all libpq-dev

接下来,您能够以root身份安装pg gem吗?

sudo su - root
gem install pg

嗨Joel。谢谢你的快速回答。 我今天只有时间来看一下,但是它没有起作用:( 它仍然抱怨说找不到Postgresql客户端库 :|我尝试在另一台32位版本的ubuntu机器上按照你的指示操作,一切都很顺利,这可能与此有关吗? - Lynx_Eyes

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