Ruby postgres problems

I have some problems with dbi which could be down to a problem installing the postgres module. The postgres module is installed, or so I thought:

···

-------------------------------------------------
[root@server /]# 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...
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/local/lib/ruby/1.8/i686-linux -I/usr/local/lib/ruby/1.8/i686-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/local/lib' -Wl,-R'/usr/local/lib' -o postgres.so postgres.o -lpq -lnsl -ldl -lcrypt -lm -lc

make install
make: Nothing to be done for `install'.
Successfully installed postgres-0.7.1
-------------------------------------------------

However, a very simple program:

-------------------------------------------------
#!/usr/bin/ruby

require "postgres"
-------------------------------------------------

fails:

-------------------------------------------------
[will@host will]$ ./pg.rb
./pg.rb:3:in `require': No such file to load -- postgres (LoadError)
         from ./pg.rb:3
-------------------------------------------------

Any ideas what is wrong here?

after running make, do you have a postgres.so file in your directory?

Dave

···

On 4/26/05, will <will@willj.net> wrote:

make
gcc -fPIC -I. -I/usr/local/lib/ruby/1.8/i686-linux
-I/usr/local/lib/ruby/1.8/i686-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/local/lib' -Wl,-R'/usr/local/lib' -o postgres.so
postgres.o -lpq -lnsl -ldl -lcrypt -lm -lc

possibly you have two rubys - perhaps 1.6 and 1.8. you may have installed it
for one and not the other. do you have two rubys?

-a

···

On Tue, 26 Apr 2005, will wrote:

I have some problems with dbi which could be down to a problem
installing the postgres module. The postgres module is installed, or so
I thought:

-------------------------------------------------
[root@server /]# 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...
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/local/lib/ruby/1.8/i686-linux
-I/usr/local/lib/ruby/1.8/i686-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/local/lib' -Wl,-R'/usr/local/lib' -o postgres.so
postgres.o -lpq -lnsl -ldl -lcrypt -lm -lc

make install
make: Nothing to be done for `install'.
Successfully installed postgres-0.7.1
-------------------------------------------------

However, a very simple program:

-------------------------------------------------
#!/usr/bin/ruby

require "postgres"
-------------------------------------------------

fails:

-------------------------------------------------
[will@host will]$ ./pg.rb
/pg.rb:3:in `require': No such file to load -- postgres (LoadError)
        from ./pg.rb:3
-------------------------------------------------

Any ideas what is wrong here?

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
although gold dust is precious, when it gets in your eyes, it obstructs
your vision. --hsi-tang

===============================================================================

Yes, the 1.8.1 and 1.8.2, /usr/local/bin/ruby is 1.8.2.

The problem seems to have resolved itself, which it can't have done by itself. I must have done something...

I can now:

require 'dbi'

and it works, or:

require 'rubygems'
require 'postgres'

works now too. Huh. Thanks for the responses.

Will.

···

Ara.T.Howard@noaa.gov wrote:

Any ideas what is wrong here?

possibly you have two rubys - perhaps 1.6 and 1.8. you may have installed it
for one and not the other. do you have two rubys?