# Fail to install postgres gem

**URL:** <https://www.ruby-forum.com/t/fail-to-install-postgres-gem/84352>\
**Category:** Ruby\
**Created:** [February 3, 2007, 3:56pm UTC](https://www.ruby-forum.com/t/fail-to-install-postgres-gem/84352 "2007-02-03T15:56:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![threeeyedfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a587f6/32.png) [@threeeyedfish](https://www.ruby-forum.com/u/threeeyedfish)\
**Post date:** [February 3, 2007, 3:56pm UTC](https://www.ruby-forum.com/t/fail-to-install-postgres-gem/84352/1 "2007-02-03T15:56:41Z")

</div>

Good day!  
I have problems installing postgres gem.  
It seems that gem cannot find my PostgreSQL installation.  
Please tell me what options can I give to gem. Gem manual doesn’t help.

I’m getting the following:

ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)  
ERROR: Failed to build gem native extension.

ruby extconf.rb install postgres  
checking for cygwin32\_socket() in -lwsock32… no  
checking for socket() in -lsocket… no  
checking for gethostbyname() in -linet… no  
checking for gethostbyname() in -lnsl… no  
checking for sys/un.h… yes  
checking for socket()… yes  
checking for hsterror()… no  
checking for gethostname()… yes  
checking for PQsetdbLogin() in -lpq… 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-pgsql-dir  
–without-pgsql-dir  
–with-pgsql-include  
–without-pgsql-include=${pgsql-dir}/include  
–with-pgsql-lib  
–without-pgsql-lib=${pgsql-dir}/lib  
–with-wsock32lib  
–without-wsock32lib  
–with-socketlib  
–without-socketlib  
–with-inetlib  
–without-inetlib  
–with-nsllib  
–without-nsllib  
–with-pgsql-include-dir  
–without-pgsql-include-dir  
–with-pgsql-lib-dir  
–without-pgsql-lib-dir  
–with-pqlib  
–without-pqlib  
Could not find PostgreSQL libraries: Makefile not created

Gem files will remain installed in  
/usr/local/lib/ruby/gems/1.8/gems/postgres-0.7.1 for inspection.  
Results logged to  
/usr/local/lib/ruby/gems/1.8/gems/postgres-0.7.1/gem\_make.out

Yours sincerely,  
Damian/Three-eyed Fish

---

<div class="post-metadata">

**Author:** ![threeeyedfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a587f6/32.png) [@threeeyedfish](https://www.ruby-forum.com/u/threeeyedfish)\
**Post date:** [February 3, 2007, 5:57pm UTC](https://www.ruby-forum.com/t/fail-to-install-postgres-gem/84352/2 "2007-02-03T17:57:12Z")

</div>

i usually install this from source (not as a gem) - this way i can  
specify where the postgresql header files and libraries live (i usually  
also build the postgresql from source).

just download the source from [http://ruby.scripting.ca/postgres/](http://ruby.scripting.ca/postgres/) and  
follow the instructions in README file.

hope this helps,

vlad

---

<div class="post-metadata">

**Author:** ![threeeyedfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a587f6/32.png) [@threeeyedfish](https://www.ruby-forum.com/u/threeeyedfish)\
**Post date:** [February 3, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/fail-to-install-postgres-gem/84352/3 "2007-02-03T18:01:52Z")

</div>

On Sat, 2007-02-03 at 23:55 +0900, Damian T. wrote:

> Gem files will remain installed in  
> /usr/local/lib/ruby/gems/1.8/gems/postgres-0.7.1 for inspection.

Hm, seems like it’s not finding the PostgreSQL header and object files.  
You can probably get it to work by moving into that directory  
(/usr/local/lib/ruby/gems/1.8/gems/postgres-0.7.1) and running:

ruby extconf.rb --with-pgsql-include-dir=/path/to/pgsql/headers  
–with-pgsql-lib-dir=/path/to/pgsql/shared\_libs

and then run “make” and “make install”.

Yours,

Tom

---

<div class="post-metadata">

**Author:** ![threeeyedfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a587f6/32.png) [@threeeyedfish](https://www.ruby-forum.com/u/threeeyedfish)\
**Post date:** [February 3, 2007, 6:58pm UTC](https://www.ruby-forum.com/t/fail-to-install-postgres-gem/84352/4 "2007-02-03T18:58:59Z")

</div>

On 2/4/07, Tom C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> and then run “make” and “make install”.

You can also achieve the same thing in one step with gem by passing  
the extconf args after ‘–’:

gem install postgres – --with-pgsql-include-dir=…

---

<div class="post-metadata">

**Author:** ![threeeyedfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a587f6/32.png) [@threeeyedfish](https://www.ruby-forum.com/u/threeeyedfish)\
**Post date:** [February 4, 2007, 3:38am UTC](https://www.ruby-forum.com/t/fail-to-install-postgres-gem/84352/5 "2007-02-04T03:38:45Z")

</div>

On Sun, 2007-02-04 at 02:43 +0900, Damian T. wrote:

> > Tom
> 
> Thank you so much!  
> Worked.

Super! The same thing happened to me with the MySQL gem yesterday, so  
it’s fresh in my mind…

Yours,

tom

---

<div class="post-metadata">

**Author:** ![threeeyedfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a587f6/32.png) [@threeeyedfish](https://www.ruby-forum.com/u/threeeyedfish)\
**Post date:** [February 3, 2007, 6:44pm UTC](https://www.ruby-forum.com/t/fail-to-install-postgres-gem/84352/6 "2007-02-03T18:44:59Z")

</div>

On Feb 3, 2007, at 20:00, Tom C. wrote:

> and then run “make” and “make install”.
> 
> Yours,
> 
> Tom

Thank you so much!  
Worked.

Yours sincerely,  
Damian/Three-eyed Fish
