How to install Ruby Postgres Gem with a remote server

Hi everyone,

I have a slight problem. I have two machines. One is an app server and
the second is the database server running postgres. How do you install
the ruby postgres api on the app server to talk to the postgres on the
database server? I’m getting some errors on the installation.

thanks,

Bing

On 6/21/06, Bing T. [email protected] wrote:

Hi everyone,

I have a slight problem. I have two machines. One is an app server and
the second is the database server running postgres. How do you install
the ruby postgres api on the app server to talk to the postgres on the
database server? I’m getting some errors on the installation.

thanks,

Bing

Hey.

Please elaborate on the situation.
which platform? what gem? some code?

:slight_smile:
/Kevin

On Wed, 2006-06-21 at 21:04 +0900, Bing T. wrote:

Hi everyone,

I have a slight problem. I have two machines. One is an app server and
the second is the database server running postgres. How do you install
the ruby postgres api on the app server to talk to the postgres on the
database server? I’m getting some errors on the installation.

You can install the pure Ruby driver using “gem install postgres-pr”.
If you want to use the native driver (i.e., “gem install postgres”)
you’ll need to install the PostgreSQL header files and libraries on the
app server so that the gem installation process can compile the driver.

Yours,

Tom

On 6/21/06, Tom C. [email protected] wrote:

On Wed, 2006-06-21 at 21:04 +0900, Bing T. wrote:

Hi everyone,

I have a slight problem. I have two machines. One is an app server and
the second is the database server running postgres. How do you install
the ruby postgres api on the app server to talk to the postgres on the
database server? I’m getting some errors on the installation.

Check out this page - it worked for me in the same situation. No
compilation
necessary.

http://www.vandomburg.net/pages/postgres-ruby-windows

*** 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.

Do you have the postgresql-devel RPMs installed? If I recall correctly,
that RPM contains the header files and libraries and whatnot.

Yours,

Tom

We have ruby version 1.8.4, fedora core 2, postgres version PostgreSQL
7.2.2
here is the error when I issue the command gem install postgres

Attempting local installation of ‘postgres’
Local gem file not found: postgres*.gem
Attempting remote installation of ‘postgres’
Building native extensions. This could take a while…
*** 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
ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in
/usr/local/lib/ruby/gems/1.8/gems/postgres-0.
7.1 for inspection.
ruby extconf.rb install postgres\nchecking 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… no
Could not find PostgreSQL libraries: Makefile not created

Results logged to
/usr/local/lib/ruby/gems/1.8/gems/postgres-0.7.1/gem_make.out

Kevin Ilchmann Jørgensen wrote:

On 6/21/06, Bing T. [email protected] wrote:

Hi everyone,

I have a slight problem. I have two machines. One is an app server and
the second is the database server running postgres. How do you install
the ruby postgres api on the app server to talk to the postgres on the
database server? I’m getting some errors on the installation.

thanks,

Bing

Hey.

Please elaborate on the situation.
which platform? what gem? some code?

:slight_smile:
/Kevin

I have Installed this rpm postgresql-7.4.7-3.FC2.1.src.rpm because I
have having trouble with the binary rpm, The source rpm was installed
correctly, but when I try the gem install postgres I still encounter the
same error above.

Bing T. wrote:

ok will try that one, thanks

Tom C. wrote:

*** 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.

Do you have the postgresql-devel RPMs installed? If I recall correctly,
that RPM contains the header files and libraries and whatnot.

Yours,

Tom

ok will try that one, thanks

Tom C. wrote:

*** 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.

Do you have the postgresql-devel RPMs installed? If I recall correctly,
that RPM contains the header files and libraries and whatnot.

Yours,

Tom

On 6/22/06, Bing T. [email protected] wrote:

I have Installed this rpm postgresql-7.4.7-3.FC2.1.src.rpm because I
have having trouble with the binary rpm, The source rpm was installed
correctly, but when I try the gem install postgres I still encounter the
same error above.

libpq provides PQsetdbLogin() (or so it tries)
http://rpmfind.net/linux/rpm2html/search.php?query=libpq.so&submit=Search+…&system=fedora&arch=

postgresql-libs is what you want.

/Kevin

Ok, so I’ve tried doing the installations but I’m now getting this error
when doing my test. It seems like the driver isn’t being seen?:

/usr/local/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in load_driver': is not a class/module (TypeError) from /usr/local/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in_get_full_driver’
from /usr/local/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in
`connect’
from ./test_connect.rb:7

Here is my test code:

#!/usr/local/bin/ruby

require “dbi”

URL = “dbi:pg:dbname:192.168.22.1:port=5432”

dbh = DBI.connect(URL,“username”,“password”)

Note that the ip address here is on a remote machine in a local loop.

thanks,

Bing

On 6/22/06, Bing T. [email protected] wrote:

google: _get_full_driver postgres
find
http://www.codecomments.com/message664869.html (first hit)

might help, anyway it cant find the driver
what is the content of your /ruby/DBD/ dir ?

Kevin Ilchmann Jørgensen wrote:

On 6/22/06, Bing T. [email protected] wrote:

google: _get_full_driver postgres
find
http://www.codecomments.com/message664869.html (first hit)

might help, anyway it cant find the driver
what is the content of your /ruby/DBD/ dir ?

Hi Kevin,

I already have pg.rb on my DBD dir :(. Looking at my test code though,
am I using it correctly? do I have the right syntax particularly my
DBI.connect?

Here it is again:

#!/usr/local/bin/ruby

require “dbi”

URL = “dbi:pg:dbname:192.168.22.1:port=5432”

dbh = DBI.connect(URL,“username”,“password”)

Bing

Btw,

here is my dir: /usr/local/lib/ruby/site_ruby/1.8/DBD/Pg/Pg.rb

hey,

in irb
what does

irb(main):002:0> require “dbi”
=> true
irb(main):003:0> DBI.available_drivers

give you ?

DBI.connect(“dbi:pg:test:192.168.22.1”, “user”, “pas”)?

/Kevin

Kevin Ilchmann Jørgensen wrote:

hey,

in irb
what does

irb(main):002:0> require “dbi”
=> true
irb(main):003:0> DBI.available_drivers

give you ?

DBI.connect(“dbi:pg:test:192.168.22.1”, “user”, “pas”)?

/Kevin

Hi Kevin,

after I type in DBI.available_drivers,

I only get: [“dbi:Pg:”]

thanks,

Bing

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs