Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
The same basic question was asked here (by the same person). –  Mark Stosberg Jun 3 '12 at 0:15
    
(Yes, it was suggested I post here - as it seems to be server related) –  A4J Jun 3 '12 at 0:21
add comment

2 Answers

up vote 1 down vote accepted

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

share|improve this answer
    
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 '12 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 '12 at 17:31
    
Thank you! That fixed the problems I was having doing a bundle install in production!! :-) –  A4J Jun 3 '12 at 18:43
add comment

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" ?

share|improve this answer
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 '12 at 0:11
    
Here is the link to the source of that gem: bitbucket.org/ged/ruby-pg/src –  A4J Jun 3 '12 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) –  Mark Stosberg Jun 3 '12 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 '12 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 '12 at 2:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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