Ruby-pg gem fails to install

i built postgres 9.0 from source and i am trying to install ruby-pg
and get the following error

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

/usr/local/bin/ruby extconf.rb
*** 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.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/local/bin/ruby
extconf.rb:4:in `': uninitialized constant Object::PLATFORM
(NameError)

Gem files will remain installed in
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-pg-0.7.9.2008.01.28 for
inspection.
Results logged to
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-pg-0.7.9.2008.01.28/ext/gem_make.out


Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

On Mon, Nov 8, 2010 at 12:52 PM, Rajinder Y. [email protected]
wrote:

i built postgres 9.0 from source and i am trying to install ruby-pg
and get the following error

ruby-pg is ancient. you want the pg gem.

Ben

On Mon, Nov 8, 2010 at 4:01 PM, Ben B. [email protected] wrote:

On Mon, Nov 8, 2010 at 12:52 PM, Rajinder Y. [email protected] wrote:

i built postgres 9.0 from source and i am trying to install ruby-pg
and get the following error

ruby-pg is ancient. you want the pg gem.

Ben

i tried the following

sudo gem install pg –
–with-pgsql-include=/opt/postgresql-9.0.1/src/interfaces/libpq

still getting an error, how do i tell it where to find the header files?

checking for pg_config… no
checking for libpq-fe.h… no
Can’t find the 'libpq-fe.h header
*** 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.


Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

Just ran into the same thing myself… installing ‘libpq-dev’ seemed to
have solved it:

sudo apt-get install libpq-dev


Alex S. | Sr. Quality Engineer | hi5 Networks, Inc. | [email protected]
| m: 415.710.6961

On Mon, Nov 8, 2010 at 2:11 PM, Rajinder Y. [email protected]
wrote:

i tried the following

sudo gem install pg –
–with-pgsql-include=/opt/postgresql-9.0.1/src/interfaces/libpq

still getting an error, how do i tell it where to find the header files?

Did you try just “sudo gem install pg”? I suspect you did and it
failed. At any rate, that’s definitely not the correct path; you
probably want something like /opt/postgresql-9.0.1/include

Run pg_config, it’ll tell you what your include dir is.

Ben

On Mon, Nov 8, 2010 at 5:23 PM, Ben B. [email protected] wrote:

probably want something like /opt/postgresql-9.0.1/include

Run pg_config, it’ll tell you what your include dir is.

Ben

i have tried the following not sure if my syntax is correct? i get the
same error

sudo gem install pg –
–with-pgsql-lib=/usr/local/pgsql/lib
–with-pgsql-include=/usr/local/pgsql/include

sudo gem install pg –
–with-pg-config=/opt/postgresql-9.0.1/src/bin/pg_config

here is the output from pg_config

BINDIR = /opt/postgresql-9.0.1/src/bin/pg_config
DOCDIR = /usr/local/pgsql/share/doc
HTMLDIR = /usr/local/pgsql/share/doc
INCLUDEDIR = /usr/local/pgsql/include
PKGINCLUDEDIR = /usr/local/pgsql/include
INCLUDEDIR-SERVER = /usr/local/pgsql/include/server
LIBDIR = /usr/local/pgsql/lib
PKGLIBDIR = /usr/local/pgsql/lib
LOCALEDIR = /usr/local/pgsql/share/locale
MANDIR = /usr/local/pgsql/share/man
SHAREDIR = /usr/local/pgsql/share
SYSCONFDIR = /usr/local/pgsql/etc
PGXS = /usr/local/pgsql/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE =
CC = gcc
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -O2 -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-fwrapv
CFLAGS_SL = -fpic
LDFLAGS = -Wl,–as-needed
-Wl,-rpath,‘/usr/local/pgsql/lib’,–enable-new-dtags
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgport -lz -lreadline -lcrypt -ldl -lm
VERSION = PostgreSQL 9.0.1


Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

On Mon, Nov 8, 2010 at 2:40 PM, Alex S. [email protected] wrote:

Just ran into the same thing myself… installing ‘libpq-dev’ seemed to
have solved it:

sudo apt-get install libpq-dev

That won’t matter on an install from source, like the OP is doing.

Ben

On Mon, Nov 8, 2010 at 5:40 PM, Alex S. [email protected] wrote:

that won’t work for me, i built postgresql 9.0 from source, libpq-dev
is for version 8.4


Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

Try this

sudo gem install pg – --with-opt-dir=/usr/local/lib/postgre/
–with-pg-dir=/usr/local/lib/postgre/

where /usr/local/lib/postgre/ should be changed to dir where your
postgresql was installed

On Mon, Nov 8, 2010 at 5:43 PM, Ben B. [email protected] wrote:

On Mon, Nov 8, 2010 at 2:40 PM, Alex S. [email protected] wrote:

Just ran into the same thing myself… installing ‘libpq-dev’ seemed to
have solved it:

sudo apt-get install libpq-dev

That won’t matter on an install from source, like the OP is doing.

Ben

Ben thanks for your clue, I got the gem to build and install. I just
needed to add the executable pg_config not just its path:

sudo gem install pg –
–with-pg-config=/opt/postgresql-9.0.1/src/bin/pg_config/pg_config


Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

Vince Vince wrote in post #967980:

Try this

sudo gem install pg – --with-opt-dir=/usr/local/lib/postgre/
–with-pg-dir=/usr/local/lib/postgre/

where /usr/local/lib/postgre/ should be changed to dir where your
postgresql was installed

That one did the trick. Thank you!

Mine was:

sudo gem install pg – --with-opt-dir=/usr/local/pgsql/
–with-pg-dir=/usr/local/pgsql/