8

我正在尝试为 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

操作系统: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 上找不到任何有用的信息。

任何帮助是极大的赞赏。

4

3 回答 3

2

安装数据库客户端、gem 和使用它时,很多事情都会出错。

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

我还依赖于从源代码安装 Ruby,或者自己直接安装,或者使用 rbenv 或 RVM(如果它在我的开发框之一上)。然后我也直接安装 pg gem,使用gem install pg; 在安装语言时,我在使用发行版时遇到了太多糟糕的经历,所以我在它上面学了老派。

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

#!/bin/sh -x

PATH=/库/PostgreSQL/9.2/bin:$PATH
宝石安装 pg

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

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

于 2013-11-18T16:39:26.913 回答
0

在我意识到这一点postgresql-devel并且postgresql-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
于 2015-02-02T18:17:17.663 回答
0

从自制软件安装和链接 postgresql 为我修复了它:

brew install postgresql
brew unlink postgresql91
brew link --overwrite postgresql
于 2018-01-23T20:43:13.803 回答