ruby - 无法在 Ubuntu 12.10 (AMD64) 上安装 gem "pg"

标签 ruby postgresql ubuntu 64-bit

我一直(未成功)尝试在我的 ruby​​ 1.9.3-p286 上安装“pg”gem,但似乎没有任何效果。

我已经安装了 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

我做错了什么?在尝试安装 gem 之前我还应该做些什么吗?

提前谢谢你。

[编辑]

好的,所以 joelparkerhenderson 的回答让我觉得路径和库可能有问题,然后继续深入挖掘......

我找到了 this很棒的帖子,它解决了!基本上问题在于RVM。所以,我的问题已经解决了,对于可能遇到同样问题的任何人,请点击链接!

最佳答案

你的错误看起来像你缺少 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

关于ruby - 无法在 Ubuntu 12.10 (AMD64) 上安装 gem "pg",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13671947/

相关文章:

postgresql - 带条件的多列唯一约束

ubuntu - 如何使用 go 命令行更改变量?

ruby - 如何强制 JRuby 使用 java Longs 而不是 Fixnums 初始化 java ArrayList?

ruby - ElasticSearch/Searchkick - LIKE 查询

ruby-on-rails - 如何使用 devise 登录用户?

mysql - Rails+MySQL 在生产环境中:数据库配置未指定适配器 (ActiveRecord::AdapterNotSpecified)

sql - 在 postgresql 中合并行

sql - 理解多重连接的问题

ubuntu - “ubuntu” 用户的 Hadoop start-dfs.sh 权限被拒绝

c++ - libxrandr 库 : how to change properties of connected monitors?