Wednesday, April 16, 2008

Capistrano now needs a pseudo-tty...

I've been using Capistrano 2.x for sometime now and really like it but ran into a strange problem a couple of days ago when attempting to deploy a new version of my website.

I had last deployed in March of this year with no problems. Since that time I had made no changes to Capistrano (no upgrades, tweaks, etc.), but on this deploy, it failed miserably. The only indicator were numerous messages saying:

** [err] stdin: is not a tty

Sometimes it caused the command to abort and sometimes it didn't.

The solution was hard to find but easy to implement. Just add the following to your deploy.rb:

default_run_options[:pty] = true

Apparently, versions up until Cap 2.1 would always allocate a pseudo-tty (pty) for every command it ran. However, with the removal of this default in Cap 2.1, "...some commands, in certain environments" fail with no pty [so says my Rails host]. Adding this new option put my deploys back in shape.

I wonder why this got removed in the first place...?