postgres gem -- LoadError

I'm at a loss to explain why the postgres gem will not work on my new
server. I've gotten it working on several other servers in the past.
The major difference between then and now is that I'm using a newer
version of PostgreSQL. 8.x as opposed to 7.x.

=== Server setup

OS: Fedora Core 6

(Commands shown with "$" are performed as the same user that mongrel
is running as. "#" are commands from root.)

$ /usr/local/pgsql/bin/psql --version
psql (PostgreSQL) 8.2.4
contains support for command-line editing

=== The error message

I'm currently running a Rails app with mongrel_cluster on ports
8000-8002. When I try to access a page, I get the following in my
production.log file.

LoadError ( cannot open shared object file: No such file or
directory - /usr/lib/ruby/gems/1.8/gems/postgres-0.7.1/./

Oddly, I can do the following.

$ irb
irb(main):001:0> require 'postgres'
=> true

Why would that work for the mongrel user at the command line, but not
from the mongrel_rails process?

=== Installing the postgres gem.

First I did a "gem install postgres" and then I tried the following.


# pwd

# make clean

# ruby extconf.rb --with-pgsql-dir=/usr/local/pgsql
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 -I. -I. -I/usr/lib/ruby/1.8/i386-linux -I. -DHAVE_SYS_UN_H -
include -fPIC -c postgres.c
gcc -shared -L"/usr/local/pgsql/lib" -L"/usr/lib" -o
postgres.o -lruby -lpq -lnsl -lpthread -ldl -lcrypt -lm -lc

# make install
/usr/bin/install -c -m 0755 /usr/lib/ruby/site_ruby/1.8/

# ldd ./ => (0x0091b000) => /usr/lib/ (0x00ef8000) => /usr/local/pgsql/lib/ (0x009b7000) => /lib/ (0x0085d000) => /lib/ (0x00110000) => /lib/ (0x00b1f000) => /lib/ (0x009d3000) => /lib/ (0x00127000) => /lib/ (0x0023b000)
        /lib/ (0x00531000)

As the mongrel user, I get the same result from ldd. I can also do
the following:

$ cd /usr/lib/ruby/gems/1.8/gems/postgres-0.7.1/

$ ls -al
total 164
drwxr-xr-x 4 root root 4096 Jun 3 11:06 .
drwxr-xr-x 17 root root 4096 Jun 3 10:50 ..
-rw-r--r-- 1 root root 5289 Jun 3 10:50 ChangeLog
drwxr-xr-x 2 root root 4096 Jun 3 10:50 doc
-rw-r--r-- 1 root root 1232 Jun 3 10:50 extconf.rb
-rw-r--r-- 1 root root 3545 Jun 3 11:06 Makefile
-rw-r--r-- 1 root root 198 Jun 3 10:50 MANIFEST
-rw-r--r-- 1 root root 7643 Jun 3 11:06 mkmf.log
-rw-r--r-- 1 root root 34307 Jun 3 10:50 postgres.c
-rw-r--r-- 1 root root 32004 Jun 3 11:06 postgres.o
-rw-r--r-- 1 root root 684 Jun 3 10:50 postgres-ruby.gemspec
-rwxr-xr-x 1 root root 33624 Jun 3 11:06
-rw-r--r-- 1 root root 2980 Jun 3 10:50 README
-rw-r--r-- 1 root root 4347 Jun 3 10:50 README.ja
drwxr-xr-x 2 root root 4096 Jun 3 10:50 sample

So I don't think that it's a permissions problem.

Is this something as simple as "PostgreSQL 8.2.4 doesn't work with
Ruby" or am I missing something else obvious here?

-- James

I removed the following packages via 'yum remove foo'.


I then removed the /usr/lib/ruby directory.

Then I compiled a new copy of ruby with the tried-and-true
'configure / make / make install'.

Re-ran the setup for ruby gems.

Installed the gems that I needed: postgres, rails, mongrel, etc.

Some old executables where hanging around in /usr/bin (Yay for yum not
removing them as instructed.)

I removed those files, and made symlinks in their place.
/usr/bin/ruby --> /usr/local/bin/ruby

The gem install postgres process still needed some hand-holding, with
the step of going into the gem directory and running everything by
hand (see my original post).

Everything works fine now.

Moral: package managers suck.

-- James