Beating a nuisance

Posted by Venerable High Pope Swanage I, Cogent Animal of Our Lady of Discord 03 August 2010 at 07:55PM

I was having a problem with trying to get rails to play nicely with my development machine. I was really frustrated with trying all kinds of various solutions, but none of them would actually work. My problem was consistent:
/usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in `rescue in rescue in establish_connection': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (no such file to load -- pg) (RuntimeError)
I beat my brains around it for about an hour or more, trying to install various versions of postgres adapters, rails stacks, and specifications in the config file. It turns out the problem was trivially simple. I started with
apt-get install ruby1.9.1-full
On a Ubuntu 10 installation. I symlinked ruby1.9.1 and irb1.9.1 to ruby and irb respectively. Then I downloaded the latest gem tarball and installed it with
ruby setup.rb
in the appropriate directory. I installed the "pg" postgres adapter, as well as rails through gems. I did not install any other adapters. My setup looked like this for various --version interrogations:
red@hugmonstar:~/eardriller$ ruby --version
ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]
red@hugmonstar:~/eardriller$ gem --version
1.3.7
red@hugmonstar:~/eardriller$ rails --version
Rails 2.3.8
red@hugmonstar:~/eardriller$  gem list pg

*** LOCAL GEMS ***

pg (0.9.0)
red@hugmonstar:~/eardriller$ 
This STILL did not work. The magic sauce was adding the following to config/environment.rb
config.gem "pg"
Once the gem was preloaded, EVERYTHING played nicely. It boggles my mind.