我正在尝试为 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 上找不到任何有用的信息。
非常感谢任何帮助。
最佳答案
安装数据库客户端、gem 和使用它时,很多事情都可能出错。
我通常从源代码而不是发行版安装 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 的位置调整了 PATH 添加,它似乎可以解决问题。我也使用了更长、更“全面”的选项,但这似乎也有效。
问题是安装程序需要从 pg_config 可执行文件中挖掘出安装信息,并且能够找到 pg_config 就可以了。
关于ruby-on-rails - pg gem install 失败说版本太旧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15301026/