I’m trying to install PostgreSQL support into Rails. This should be fairly simple. Unfortunately, there are a couple of “oopsies” along the way.
First up, there are several gems to pick along the way:
If you’ve a compiler installed, you want ruby-postgres. It’s a fork of the postgres gem, which knows how to find the postgres libraries and headers through pg_config. The postgres-pr gem is a pure-ruby version.
Being foolish, I tried to install the postgres gem:
% gem install ruby-postgres-0.7.1.2006.04.06.gem
Sadly, this is what happens:
Building native extensions. This could take a while... ruby extconf.rb install -l ruby-postgres-0.7.1.2006.04.06.gem ... make install make: Nothing to be done for `install'.
Finished prerequisites of target file `/opt/domtest/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06/./postgres.so'. Prerequisite `postgres.so' is older than target `/opt/domtest/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06/./postgres.so'. No need to remake target `/opt/domtest/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06/./postgres.so'. Finished prerequisites of target file `install-so'.
Basically, the freshly-compiled postgres.so is older than the installed version. Which isn’t installed, BTW. I checked. How can this be?
After much messing around, I discovered that the reason is that ruby gems compiles in place. So when it comes to install time, it ends up comparing the compiled file to itself. Naturally, nothing happens.
But then, ruby gems runs
make clean, causing it to be removed. Grrr! How on earth has this ever worked for anybody?
Anyway, at this point, I’m going to give up and use the postgres-pr gem instead.
 I’m not the first to see this—see ruby postgres problems.