【问题标题】:Not able to install pg gem on Ubuntu 12.10无法在 Ubuntu 12.10 上安装 pg gem
【发布时间】:2013-01-06 19:41:55
【问题描述】:

我使用的是 Ubuntu 12.10 64 位,并且安装了以下软件包:

dpkg --get-selections | grep postgre

输出:

postgresql
postgresql-9.1
postgresql-client
postgresql-client-9.1
postgresql-client-common
postgresql-common
postgresql-contrib
postgresql-contrib-9.1
postgresql-server-dev-9.1
postgresql-server-dev-all
libpq-dev
libpq5

rvm 1.17.9

ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux]

我无法安装 pg gem 我收到以下错误:

ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /home/vedarthk/.rvm/rubies/ruby-1.9.3-p362/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)

我也尝试了以下命令,但输出与上面相同:

gem install pg -- --with-pg-include=/usr/include/postgresql/libpq --with-pg-lib=/usr/lib/postgresql/9.1/lib


gem install pg -- --with-pg-include=/usr/include/postgresql --with-pg-lib=/usr/lib/postgresql/9.1/lib

【问题讨论】:

  • 尝试安装build-essential 包,如下所述:stackoverflow.com/a/12269483/429758。该线程中的其他答案 - 特别是关于 rvmsudo 的答案 - 可能也会有所帮助。
  • 我确实这样做了,但 build-essential 已经安装并且我有最新版本。

标签: ruby gem postgresql-9.1 pg ubuntu-12.10


【解决方案1】:

我在 RHEL 6.4 上遇到了类似的问题,以下对我有用:

gem install /opt/redmine/vendor/cache/pg-0.18.4.gem --local -- --with-pg-dir=/usr/pgsql-9.4/

我从他们自己的存储库设置 PostgreSQL。

【讨论】:

    【解决方案2】:

    尝试安装 PostgreSQL 开发头文件:

    sudo apt-get install libpq-dev

    【讨论】:

    【解决方案3】:

    试试 - $ sudo apt-get install ruby​​-dev

    sudo gem install pg won't work 有这个解决方案,它对我有用。

    【讨论】:

    • 我正在使用 rvm,使用 sudo apt-get install ruby-dev 给我一个错误 ruby-dev : Depends: ruby1.9.1-dev (>= 1.9.3.194-1) but it is not going to be installed
    猜你喜欢
    • 2012-11-20
    • 1970-01-01
    • 2015-04-06
    • 2016-03-27
    • 2020-02-28
    • 2013-02-20
    • 2015-03-16
    • 1970-01-01
    相关资源
    最近更新 更多