uninitialized constant PGconn

I’m successfully using Postgres for development. My stack includes ruby 1.8.7, rails 2.3.4, and pg 0.8.0. One day, I get an error

NameError: uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PGconn

I didn’t update Postgres or the pg gem so I don’t see a reason for it to stop working. Then I remember that I installed jruby and installed the activerecord adapater. Instead of using jgem install, I used gem install. This installed the gems (activerecord-jdbc-adapter, activerecord-jdbcmysql-adapter and jdbc-mysql) on my ruby 1.8.7 system. I left the gems installed thinking they wouldn’t cause any error.

So, if you encounter uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PGconn check if you have the jdbc adapter gems for jruby.

I hope this helps someone.

Capistrano 2.5.11 Latest Release Workaround

A recent commit in Capistrano broke some of the deploys. The latest_release directory becomes the oldest release instead of the most recent. Some of the effects I’ve seen are: 1) rake db:migrate is run on the oldest release 2) deploy:cleanup deletes the most recent releases.

When you deploy, and the number of releases directories exceed keep_releases, deploy:cleanup would delete the directory that you’re trying to deploy. You’ll end up with current that symlinks to a missing directory.

You can follow the ticket on lighthouse. In the meantime, you can use a workaround. On your deploy.rb, add

set :releases, lambda { capture("ls -x #{releases_path}").split.sort }