Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg gem install fails saying version is too old?

I am trying to install the pg (PostreSQL) gem for Ruby. I am receiving this error:

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 version: postgres (PostgreSQL) 9.2.3

OS: solaris 10

I have also tried:

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

I have no idea why this error is occurring and I cannot find any useful info on Google.

Any help is greatly appreciated.

like image 868
arrowill12 Avatar asked Mar 08 '13 18:03

arrowill12


2 Answers

Lots of things can go wrong installing a database client, the gem and using it.

I generally install PostgreSQL from source, not from a distro. At that point I know I have all the source and know exactly where things got installed. That's important when installing the gem that talks to the client drivers.

I also rely on installing Ruby from source, either by directly installing it myself, or by using rbenv or RVM if it's on one of my development boxes. Then I also install the pg gem directly, using gem install pg; I've had too many bad experiences using distros when installing languages so I go old-school on it.

I wrote a little script I use on my Mac OS systems, that I've found useful for my CentOS Linux boxes:

#!/bin/sh -x

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

I adjust the PATH addition depending on where PostgreSQL got installed, and it seems to do the trick. I've used the longer, more "comprehensive" options also, but this seems to work as well.

The issue is that the installer needs to dig out installation information from the pg_config executable and being able to find pg_config does the trick.

like image 109
the Tin Man Avatar answered Nov 13 '22 20:11

the Tin Man


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
like image 25
Mirko Avatar answered Nov 13 '22 22:11

Mirko