pg gem install失败说版本太旧了?

时间:2013-03-08 18:41:14

标签: ruby-on-rails ruby gem rails-postgresql pg

我正在尝试为Ruby安装pg(PostreSQL)gem。我收到此错误:

postgres/9.2-pgdg/bin/64/pg_config
Using config values from /location/to/install/postgres/9.2-pgdg/bin/64/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... yes
checking for PQconnectionUsedPassword()... no
Your PostgreSQL is too old. Either install an older version of this gem or upgrade your       database.
*** 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.

PostgreSQL版本:postgres(PostgreSQL)9.2.3

OS:solaris 10

我也尝试过:

gem install pg  -- --with-pgsql-lib=/location/of/install/postgres/9.2-pgdg/lib/64/ --with-pg-config=/location/of/install/postgres/9.2-pgdg/bin/64/pg_config

我不知道为什么会出现此错误,而且我在Google上找不到任何有用的信息。

非常感谢任何帮助。

3 个答案:

答案 0 :(得分:2)

安装数据库客户端,宝石并使用它时会出现很多问题。

我通常从源代码安装PostgreSQL,而不是从发行版安装。那时我知道我有所有的来源,并确切知道安装的地方。在安装与客户端驱动程序通信的gem时,这一点非常重要。

我还依赖于从源代码安装Ruby,可以通过自己直接安装,也可以使用rbenv或RVM(如果它位于我的一个开发盒上)。然后我还使用gem install pg直接安装pg gem;我在安装语言时使用发行版有太多糟糕的经历,所以我就去上学了。

我写了一个我在Mac OS系统上使用的小脚本,我觉得这对我的CentOS Linux盒很有用:

#!/bin/sh -x

PATH=/Library/PostgreSQL/9.2/bin:$PATH
gem install pg

我根据PostgreSQL的安装位置调整PATH添加,似乎可以解决问题。我也使用了更长,更“全面”的选项,但这似乎也有效。

问题是安装程序需要从pg_config可执行文件中挖掘出安装信息,并且能够找到pg_config。

答案 1 :(得分:0)

我很清楚这一点,直到我意识到postgresql-develpostgresql-libs来自8.1.23 !!!

$ yum list installed postgres*
Loaded plugins: fastestmirror, security
Installed Packages
postgresql-devel.i386                           8.1.23-10.el5_10                       installed
postgresql-devel.x86_64                         8.1.23-10.el5_10                       installed
postgresql-libs.i386                            8.1.23-10.el5_10                       installed
postgresql-libs.x86_64                          8.1.23-10.el5_10                       installed

---------------

$ sudo yum install postgresql94-libs
$ sudo yum install postgresql94-devel

$ gem install pg
Successfully installed pg-0.18.1

答案 2 :(得分:0)

从homebrew安装和链接postgresql为我修复了它:

brew install postgresql
brew unlink postgresql91
brew link --overwrite postgresql
相关问题