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...?

Thursday, July 19, 2007

Capistrano on Windows client...

It was supposed to be easy: just read the Capistrano manual make a little magic with your deploy.rb file, and you're in business. Sounds wonderful, doesn't it? Would that it were so easy.

The documentation (manual and elsewhere) makes it clear that Cap'ping to a Windows server is pretty challenging... Cap is made for *nix machines. However, I didn't find anything about a Windows client, other than the statement that "you must have an svn client installed on your machine." I did -- RapidSVN, TortoiseSVN, and the svn client embedded in the Aptana IDE.

However, once I got to actually attempting to deploy my application, it failed every time with a "no such file or directory" error message and a reference to the repository trunk itself. No amount of hair-pulling (it was a VERY long weekend), searching the web, emailing a few contacts helped... not matter what I did, it continued to fail in exactly the same manner. I even built a new development environment on another machine just to make sure it wasn't some brain-dead Windows issue: no dice.

Tuesday night, I went to the local Ruby on Rails Meetup and got the answer from another Windows-based developer Hob Spillane -- thanks!

So... drum roll please... here's how to get Cap working on your system:

You MUST have the svn binaries installed on your Windows client machine and in your execution path before Cap can deploy successfully -- the GUI clients do not provide what Capistrano needs. The binary you need depends on the version of Apache that your provider is running: 2.0 and 2.2 require different binaries.

For my Apache 2.2, I went to the subversion download page, and clicked on the svn-win32-1.4.4.zip link, installed it in /usr/bin/svn/bin, added that directory to my PATH statement and -- voila! -- Capistrano deploys like a charm! (When I went to the download site, there was only the choice of a zip file, no setup.exe. That may change by the time you get there.)

If your version is Apache 2.0, go to this download page and chose the appropriate setup.exe or .zip file.

Nice...