Rails Help: Rails3 和 Postgresql-8.4.3

dxdxdx · 2011年12月31日 · 最后由 wangyzyoga 回复于 2013年09月18日 · 4916 次阅读

环境: Ubuntu 10.04 LTS - Lucid Lynx rvm 1.2.7 ruby-1.9.2p136 postgresql-8.4.3 rails-3.1.3

postgresql 是通过 apt-get 安装的。

在安装 pg 这个 gem 的时候报错了,

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

/home/jim/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb checking for pg_config... no No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config checking for libpq-fe.h... no Can't find the 'libpq-fe.h header *** 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/jim/.rvm/rubies/ruby-1.9.2-p136/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

google 了一下,应该要安装 libpq-dev 这个库,于是 sudo apt-get install libpq-dev 很不幸,又抛错了

有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是 因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件 包尚未被创建或是它们已被从新到 (Incoming) 目录移出。 下列信息可能会对解决问题有所帮助:

下列软件包有未满足的依赖关系: libpq-dev: 依赖:libpq5 (= 8.4.3-1) 但是 8.4.8-0ubuntu0.10.04 正要被安装 依赖:libssl-dev 但是它将不会被安装 E: 破损的软件包

不知道大家有没有遇到类似的问题,有使用 postgresql 的同学能否指导一下? 谢谢

找到解决方法了, gem install pg -- --with-pg-config=/usr/local/pgsql/bin/pg_config /usr/local/pgsql/bin/pg_config是我电脑上的pg_config路径 如果用 bundle,可以 bundle config build.pg --with-pg-config=/usr/local/pgsql/bin/pg_config bundle install

前几天刚刚修正一个类似的问题,我用的是 pg 9.1.2

匿名 #3 2012年03月18日

遇到一模一样的问题~~可为什么我找不到 pg_config 呢?从 apt-get 中安装的 postgresql-8.4 阿

#3 楼 @funfriend 你还记得,当初是怎么解决这个问题的么?我用的是 fedora 的系统,不能 yum install libpq-dev ,所以,我也没有找到 pg_config.

匿名 #5 2013年01月26日

#4 楼 @zhangyuxiu 不清楚 fedora 的情况,记得当初这个包依赖问题我是靠 aptitude 解决的。。

我也遇到相同问题,但是通过 sudo apt-get install libpq-dev,就解决。

本机环境: Ubuntu 12.04 LTS rvm 1.22.1 ruby 1.9.3p448 rails-3.2.13

需要 登录 后方可回复, 如果你还没有账号请 注册新账号