# Problems installing postgres in Ruby

**URL:** <https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021>\
**Category:** Rails\
**Created:** [September 26, 2006, 2:33pm UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021 "2006-09-26T14:33:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torkel\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@Torkel\_M](https://www.ruby-forum.com/u/Torkel_M)\
**Post date:** [September 26, 2006, 2:33pm UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021/1 "2006-09-26T14:33:39Z")

</div>

Hi,

I got some problems getting the postgres installed in Ruby. This  
is the output I get:

# gem install postgres

Building native extensions. This could take a while…  
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… yes  
checking for sys/un.h… yes  
checking for socket()… yes  
checking for hsterror()… no  
checking for gethostname()… yes  
checking for PQsetdbLogin() in -lpq… yes  
checking for PQsetClientEncoding()… yes  
checking for pg\_encoding\_to\_char()… yes  
checking for PQescapeString()… yes  
creating Makefile

make  
gcc -fPIC -I. -I/usr/lib/ruby/1.8/i386-linux  
-I/usr/lib/ruby/1.8/i386-linux -I. -DHAVE\_SYS\_UN\_H -DHAVE\_SOCKET  
-DHAVE\_GETHOSTNAME -DHAVE\_PQSETCLIENTENCODING -DHAVE\_PG\_ENCODING\_TO\_CHAR  
-DHAVE\_PQESCAPESTRING -c postgres.c  
gcc -shared -L"/usr/lib" -o postgres.so postgres.o -lruby -lpq -lnsl  
-ldl -lcrypt -lm -lc

make install  
make: Nothing to be done for `install’.

make clean  
Successfully installed postgres-0.7.1

It ends sucessfully so it looks ok except for the fact that make install  
doesnt do anything.

But when I test it I get:

# ruby -e ‘require “rubygems”; require\_gem “postgres”;’

/usr/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require': no such file to load -- postgres (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
from /usr/lib/ruby/site\_ruby/1.8/rubygems.rb:229:in `activate' from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:228:in`activate’  
from /usr/lib/ruby/site\_ruby/1.8/rubygems.rb:66:in  
`active_gem_with_options' from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:59:in`require\_gem’  
from -e:1

Can anyone here help me out?

Regards,  
Torkel

---

<div class="post-metadata">

**Author:** ![Torkel\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@Torkel\_M](https://www.ruby-forum.com/u/Torkel_M)\
**Post date:** [September 26, 2006, 5:19pm UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021/2 "2006-09-26T17:19:19Z")

</div>

On 9/26/06, Torkel M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> checking for cygwin32\_socket() in -lwsock32… no  
> checking for PQescapeString()… yes  
> make install
> 
> # ruby -e ‘require “rubygems”; require\_gem “postgres”;’
> 
> Can anyone here help me out?
> 
> Regards,  
> Torkel
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

have you considered using the “pure ruby” version?

gem install postgres-pr

---

<div class="post-metadata">

**Author:** ![Torkel\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@Torkel\_M](https://www.ruby-forum.com/u/Torkel_M)\
**Post date:** [September 27, 2006, 12:09pm UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021/3 "2006-09-27T12:09:12Z")

</div>

Aaron K. wrote:

> have you considered using the “pure ruby” version?
> 
> gem install postgres-pr

Yes. I did try that earlier and I got that installed and working with  
the test from above.

However I did not get it to work from the program that I want this for  
so I don’t know if its supported. Is postgres and postgres-pr different  
in any case or should both work from any program?

Its the new Metasploit I want to try if anyone got any more tips then.

---

<div class="post-metadata">

**Author:** ![Torkel\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@Torkel\_M](https://www.ruby-forum.com/u/Torkel_M)\
**Post date:** [September 27, 2006, 3:30pm UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021/4 "2006-09-27T15:30:56Z")

</div>

On Tue, 26 Sep 2006 14:33:39 +0200, Torkel M. wrote:

> It ends sucessfully so it looks ok except for the fact that make install  
> doesnt do anything.

I just had exactly the same problem installing the ruby-postgres-0.7.1  
gem,  
which I -believe- is the latest version of what used to just be called  
the  
“postgres” gem. It seemed to install, yet ‘require "postgres’" failed.

I’m using Postgres 8.1 on Ubuntu 6.06. I’d previously used Postgres 8.0  
on  
Mandrake 10 with no problems.

Torkel, which Postgres and what OS?

Can anyone confirm my recollection that ruby-postgres is the rightful  
descendant of postgres? The postgres gem itself wouldn’t build on my  
system, as it depends on libpq-fe.h which is apparently missing from 8.1  
(or at least Ubuntu’s packaging of it).

Jay L.

---

<div class="post-metadata">

**Author:** ![Torkel\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@Torkel\_M](https://www.ruby-forum.com/u/Torkel_M)\
**Post date:** [September 28, 2006, 9:33am UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021/5 "2006-09-28T09:33:48Z")

</div>

Jay L. wrote:

> I’m using Postgres 8.1 on Ubuntu 6.06. I’d previously used Postgres 8.0  
> on Mandrake 10 with no problems.
> 
> Torkel, which Postgres and what OS?

Postgres 8.1.4-1 and Fedora Core 5

Did you do “gem install postgres” or “gem install ruby-postgres” ?

---

<div class="post-metadata">

**Author:** ![Torkel\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@Torkel\_M](https://www.ruby-forum.com/u/Torkel_M)\
**Post date:** [September 30, 2006, 10:19pm UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021/6 "2006-09-30T22:19:07Z")

</div>

Looks like it gets installed, but not built on my FC5 setup:

How I got it to work:

gem install postgres  
cd /usr/lib/ruby/gems/1.8/gems/postgres-0.7.1/  
make

---

<div class="post-metadata">

**Author:** ![Torkel\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@Torkel\_M](https://www.ruby-forum.com/u/Torkel_M)\
**Post date:** [September 28, 2006, 7:11pm UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021/7 "2006-09-28T19:11:01Z")

</div>

On Thu, 28 Sep 2006 09:33:48 +0200, Torkel M. wrote:

> Postgres 8.1.4-1 and Fedora Core 5

Interesting.

> Did you do “gem install postgres” or “gem install ruby-postgres” ?

I tried both. “gem install postgres” failed to build the native  
extension;  
it depends on libpq-fe.h which is apparently gone in 8.1. “gem install  
ruby-postgres”, which I believe is the updated replacement for the  
former,  
appeared to succeed but then was still “missing”.

Maybe someone will have the answer…

Jay

---

<div class="post-metadata">

**Author:** ![Torkel\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@Torkel\_M](https://www.ruby-forum.com/u/Torkel_M)\
**Post date:** [October 3, 2006, 10:02am UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021/8 "2006-10-03T10:02:04Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Looks like it gets installed, but not built on my FC5 setup:
> 
> How I got it to work:
> 
> gem install postgres  
> cd /usr/lib/ruby/gems/1.8/gems/postgres-0.7.1/  
> make

Thank you. It works now!

Regards,  
Torkel

---

<div class="post-metadata">

**Author:** ![Torkel\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@Torkel\_M](https://www.ruby-forum.com/u/Torkel_M)\
**Post date:** [October 7, 2006, 10:03am UTC](https://www.ruby-forum.com/t/problems-installing-postgres-in-ruby/70021/9 "2006-10-07T10:03:49Z")

</div>

Torkel M. wrote:

> Regards,  
> Torkel

This fixed my install of ruby-postgres on Ubuntu Dapper as well. The  
extra make put files postgres.o and postgres.so into the  
/usr/local/lib/site\_ruby/gems/gems/ruby-postgres-0.7.1.2006.04.06  
directory.

Tony
