April 29, 2007

Cap upgrade:revisions problem (and solution)

I just upgraded to version 1.99 of Capistrano, the remote deployment tool most commonly used for Rails projects. This is a prerelease of Capistrano 2.0 and installed easily with the following commands:

sudo gem install highline
sudo gem install -s http://gems.rubyonrails.com capistrano

Highline is a new (at least on my machine) dependency for Capistrano and needs to be installed separately because it isn’t present in the gems.rubyonrails.org repository. Following the upgrade instructions I ran capify . in my local working copy to upgrade my recipe setup. I then ran cap -f upgrade upgrade:revisions to upgrade the remote revision tracking files. Sadly, that didn’t work very well and I was greeted with a mostly unhelpful little error:

* executing <code>upgrade:revisions'
/usr/local/lib/ruby/gems/1.8/gems/capistrano-1.99.0/lib/capistrano/configuration/namespaces.rb:175:inmethod_missing': undefined local variable or method `deploy_to' for #<Capistrano::Configuration::Namespaces::Namespace:0x69e8a8> (NameError)
</code>

It took a little looking about, but I figured out how to fix it: just run this command:

cap -f upgrade -f Capfile upgrade:revisions

All better.