Busy debugging at night...

(Also known as “why doesn’t Capistrano pick up my changes???”)

One of the cool things about Capistrano is that you don’t even have to put your Capistrano files into your app repo. You can put the Capfile and config/deploy.rb and so on in a different repo, or its own repo, or no repo or whatever.

One of the really infuriating things about Capistrano is that it’s designed to allow you to do that. See the bottom of this post for a quick workaround, or just keep reading.

Which means that even if you put Capistrano into your app repo, you’ll need to commit and push your changes so that Capistrano can deploy them wherever they go. This can be a really frustrating edit/debug cycle, especially if you forget to push for awhile and spend your time shouting “why doesn’t this fix the bug?”

Workaround

Like many things, the workaround is simple: automation. I’m a big fan of having a deploy shellscript in my projects and always using it.

Instead of running Capistrano directly (“cap development deploy”), make a deploy shellscript that runs something like:

  git diff-index --quiet HEAD && git push && cap development deploy

This makes sure there are no modified files in your Git repo. Then it pushes your commits to master. Then it deploys.

Do that and you shouldn’t have to worry “did I push?”

Then you can get back to real debugging.