# PostgreSQL gem for Ruby (pg) problem!

**URL:** <https://www.ruby-forum.com/t/postgresql-gem-for-ruby-pg-problem/150648>\
**Category:** Rails\
**Created:** [October 10, 2008, 8:39pm UTC](https://www.ruby-forum.com/t/postgresql-gem-for-ruby-pg-problem/150648 "2008-10-10T20:39:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@The\_N](https://www.ruby-forum.com/u/The_N)\
**Post date:** [October 10, 2008, 8:39pm UTC](https://www.ruby-forum.com/t/postgresql-gem-for-ruby-pg-problem/150648/1 "2008-10-10T20:39:29Z")

</div>

Hi there.

I’m having a problem here: I’m trying to install pg-0.7.9.2008.10.05  
(The last version), but I get this…

PATH=/opt/PostgreSQL/8.3/bin:$PATH gem install pg  
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 install pg  
checking for main() in -lpq… no  
checking for main() in -llibpq… no  
checking for main() in -lms/libpq… no  
\*\*\* 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  
–with-pg-dir  
–without-pg-dir  
–with-pg-include  
–without-pg-include=${pg-dir}/include  
–with-pg-lib  
–without-pg-lib=${pg-dir}/lib  
–with-pqlib  
–without-pqlib  
–with-libpqlib  
–without-libpqlib  
–with-ms/libpqlib  
–without-ms/libpqlib  
Could not find PostgreSQL build environment (libraries & headers):  
Makefile not created

It mentions 3 files missing as you can see, but that’s impossible,  
because I installed PostgreSQL 8.3.4 via a Linux installer. What could  
be wrong? The version I’m using now, ruby-pg-0.7.9.2008.01.28, can be  
installed flawlessly and doesn’t give me any errors, but I’m worried  
about the ActiveRecord support my gem doesn’t have and the latest  
version does.

Can you help me? I’m working with a company in a project with Rails  
2.1 and PostgreSQL 8.3.4. It’s urgent!!! Any ideas?

Greetings and thanks in advance.

Juan Escajadillo.

---

<div class="post-metadata">

**Author:** ![The\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@The\_N](https://www.ruby-forum.com/u/The_N)\
**Post date:** [October 19, 2008, 2:22pm UTC](https://www.ruby-forum.com/t/postgresql-gem-for-ruby-pg-problem/150648/2 "2008-10-19T14:22:19Z")

</div>

Hi,

That’s how I installed the postgres gem on my Mac:

sugo gem install postgres – --with-pgsql-dir=/Library/PostgreSQL/8.3

Then in database.yml, specify the postgresql adapter.

Everything works perfectly on my side with PostgreSQL 8.3.4 binary  
package.
