2013-03-08 109 views
7

我想为Ruby安装pg(PostreSQL)gem。我收到此错误:pg gem install说版本太旧?

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上找到任何有用的信息。

任何帮助,非常感谢。

+0

我有多个版本,但我指向正确的版本也mkmf.log我看到了同样的错误引用pQconnectionUsedPassword( )。 – arrowill12 2013-03-08 20:29:54

+2

您可能需要设置'PATH'来确保正确的'pg_config'可执行文件在PATH中处于第一位,并设置任何'LD_LIBRARY_PATH'或Solaris等效环境变量以确保找到正确的'libpq'。 – 2013-03-09 00:37:45

+0

“mkmf.log”在检查“PQconnectionUsedPassword”存在的部分中说了些什么? – 2013-03-09 15:06:17

回答

2

很多事情可能会出错安装数据库客户端,宝石和使用它。

我通常从源代码安装PostgreSQL,而不是从发行版安装。在那一点上,我知道我有所有的来源,并确切知道事情的安装位置。安装与客户端驱动程序交流的gem时,这一点很重要。

我还依赖从源代码安装Ruby,可以直接自己安装,也可以通过使用rbenv或RVM(如果它位于我的开发框之一)来安装。然后我也直接安装pg gem,使用gem install pg;在安装语言时,我有很多使用发行版的不好的经历,所以我就此放弃了老生常谈。

我写了一个小脚本,我在我的Mac OS系统使用,我发现有用我的CentOS Linux机器:

 
#!/bin/sh -x 

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

我调整路径除了取决于安装得到了PostgreSQL的地方,它似乎有窍门。我已经使用了更长,更“全面”的选项,但这似乎也适用。

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

+0

每次都有作品。 – pzin 2015-01-10 10:23:32

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 
0

安装和连接和PostgreSQL自制固定对我来说:

brew install postgresql 
brew unlink postgresql91 
brew link --overwrite postgresql