I'm trying to install the PG (postgres) gem on a CentoOS server, but it keeps saying Postgres is too old, even though I have upgraded it to 9.1.3 (as per the instructions here http://www.davidghedini.com/pg/entry/install_postgresql_9_on_centos).

I am using CentOS 5.8 (and Ruby 1.9.3)

Here is the error message:

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

        /usr/local/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/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.

psql --version confirms my version: psql (PostgreSQL) 9.1.3

I can confirm packages installed:

Setting up Install Process
Package postgresql91-9.1.3-1PGDG.rhel5.x86_64 already installed and latest version
Package postgresql91-devel-9.1.3-1PGDG.rhel5.x86_64 already installed and latest version
Package postgresql91-server-9.1.3-1PGDG.rhel5.x86_64 already installed and latest version
Package postgresql91-libs-9.1.3-1PGDG.rhel5.x86_64 already installed and latest version
Package postgresql91-contrib-9.1.3-1PGDG.rhel5.x86_64 already installed and latest version
Nothing to do

Any ideas on how to troubleshoot this? Thanks in advance.

  • The same basic question was asked here (by the same person). Jun 3, 2012 at 0:15
  • (Yes, it was suggested I post here - as it seems to be server related)
    – A4J
    Jun 3, 2012 at 0:21

3 Answers 3


Your ruby gem is probably picking up the old development libraries. Typically you will to add /usr/pgsql-9.0/include/ to your includes.

  • I managed to do it last night with 'gem install pg -- --with-pgsql-lib=/usr/pgsql-9.1/lib --with-pg-config=/usr/pgsql-9.1/bin/pg_config' - was there a better way? Do I still need to add pg9 to my includes? (If so how?) Thanks.
    – A4J
    Jun 3, 2012 at 11:10
  • It looks like you got it, the --with-pg-config command executes a command that spits out all the right configuration stuff. That said, you could make it a permanent change and eliminate the need for extra flags by adjusting your path so /usr/pgsql-9.1/bin was in your path first.
    – easel
    Jun 3, 2012 at 17:31
  • Thank you! That fixed the problems I was having doing a bundle install in production!! :-)
    – A4J
    Jun 3, 2012 at 18:43

Since you are running the latest version of PostgreSQL, it seems very unlikely that it is really too old. I would look at the source code of whatever is generating that error and look for a bug in there. How is it calculating that PostgreSQL is "too old" ?

  • 1
    I'm not sure to tbh, but I have a sneaky suspicion it might be to do with associated packages, as it errors out after this line: checking for PQconnectionUsedPassword(). And I have seen similar posts where it's suggested to install the development packages (but I seem to have them)
    – A4J
    Jun 3, 2012 at 0:11
  • Here is the link to the source of that gem: bitbucket.org/ged/ruby-pg/src
    – A4J
    Jun 3, 2012 at 0:20
  • In the source, it contains have_func 'PQconnectionUsedPassword' or abort. I can also see that PQconnectionUsedPassword is in the current version of PostgreSQL. It looks like your "libpq-fe.h" might be old. Use 'locate' to find this file on your system and see if you have multiple copies of it, and see how old each on is (with ls -l) Jun 3, 2012 at 0:46
  • I tried 'locate libpq-fe.h' but it returns nothing. However just before that (and before seeing your reply) I erased everything (with yum erase postgresql91*) and reinstalled it following the guide in my first post, but now it gets stuck on 'checking for libpq-fe.h' saying it 'Can't find the 'libpq-fe.h header'. It's meant to come from this package postgresql-devel (which I have - apparently). I must be doing something wrong :/
    – A4J
    Jun 3, 2012 at 1:20
  • This seems to have done it! gem install pg -- --with-pgsql-lib=/usr/pgsql-9.1/lib --with-pg-config=/usr/pgsql-9.1/bin/pg_config (Will verify tomorrow tho as it's gone 3am)
    – A4J
    Jun 3, 2012 at 2:12

Pasted from https://stackoverflow.com/questions/15301026/pg-gem-install-fails-saying-version-is-too-old/28284126#28284126

I was going nuts with this until I realized that postgresql-devel and postgresql-libs were from 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.