# Ruby-pg gem fails to install

**URL:** <https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829>\
**Category:** Ruby\
**Created:** [November 8, 2010, 9:53pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829 "2010-11-08T21:53:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 8, 2010, 9:53pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/1 "2010-11-08T21:53:24Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [November 8, 2010, 10:02pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/2 "2010-11-08T22:02:49Z")

</div>

On Mon, Nov 8, 2010 at 12:52 PM, Rajinder Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [November 8, 2010, 11:15pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/3 "2010-11-08T23:15:49Z")

</div>

On Mon, Nov 8, 2010 at 4:01 PM, Ben B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Mon, Nov 8, 2010 at 12:52 PM, Rajinder Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://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

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [November 8, 2010, 11:41pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/4 "2010-11-08T23:41:35Z")

</div>

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. | [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
| m: 415.710.6961

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [November 8, 2010, 11:23pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/5 "2010-11-08T23:23:59Z")

</div>

On Mon, Nov 8, 2010 at 2:11 PM, Rajinder Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [November 8, 2010, 11:43pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/6 "2010-11-08T23:43:28Z")

</div>

On Mon, Nov 8, 2010 at 5:23 PM, Ben B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://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

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [November 8, 2010, 11:45pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/7 "2010-11-08T23:45:21Z")

</div>

On Mon, Nov 8, 2010 at 2:40 PM, Alex S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [November 8, 2010, 11:49pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/8 "2010-11-08T23:49:45Z")

</div>

On Mon, Nov 8, 2010 at 5:40 PM, Alex S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://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

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [December 13, 2010, 12:03am UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/9 "2010-12-13T00:03:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [November 9, 2010, 12:01am UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/10 "2010-11-09T00:01:40Z")

</div>

On Mon, Nov 8, 2010 at 5:43 PM, Ben B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Mon, Nov 8, 2010 at 2:40 PM, Alex S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://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

---

<div class="post-metadata">

**Author:** ![Rajinder\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rajinder\_Y](https://www.ruby-forum.com/u/Rajinder_Y)\
**Post date:** [December 24, 2010, 9:46pm UTC](https://www.ruby-forum.com/t/ruby-pg-gem-fails-to-install/198829/11 "2010-12-24T21:46:09Z")

</div>

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/
