Capistrano to deploy to Mac OS X?


We’re moving some “internal use” apps to a spare internal machine -
of a public, shared host. I’m not sure if it’s relevant, but the new
is running OS 10.3.

I’m having a strange problem using Capistrano. It happens on both our
development machines, and only when deploying to this server.

I run ‘cap deploy’ and get:

in process!': command "if [[ ! -d /Users/www/myappnamehere/releases/20060516200956 ]]; then svn co --username josh -q -r741 http://mysvn/myappnamehere/trunk/Users/www/myappnamehere/releases/20060516200956 && (test -e /Users/www/myappnamehere/revisions.log || touch /Users/www/myappnamehere/revisions.log && chmod 666 /Users/www/myappnamehere/revisions.log) && echodate +"%Y-%m-%d
%H:%M:%S"` $USER 741 20060516200956 >>
fi" failed

If I paste this command into terminal on the new server, I get:

date: illegal format

Eye-balling it, it looks like this might be backslashes on the ""s, so I
strip those, and try again… and it works. So, I can manually check-out
project, using the same commands as Capistrano would use, but I can’t

I suppose it shows how dependent on Capistrano I’ve become, that this
me so.

I’ve been staring at this all day, so I’m probably going cross-eyed, but
can’t see what would be causing this to happen?


Looks like Mac OS X’s date command isn’t compatible with that syntax:

~: date +"%Y-%m-%d %H:%M:%S"
date: illegal time format
usage: date [-nu] [-r seconds] [+format]
date [[[[[cc]yy]mm]dd]hh]mm[.ss]

I’d grab the gnu source, build and install it into /usr/local/bin,
and make sure your deployment user environment had /usr/local/bin
first in PATH.

– Tom M.


Wow… Okay, easier said than done, but I’ll keep digging…

Are the slash-quotes part of the command, or are they being escaped in
error output? Because when I take the slashes out, it works. Which makes
suspicious, is all I’m saying.

Is anybody else using Cap to deploy to OS X having this problem?


So, continuing with this…

The command in question comes from:

def logging_commands(directory = nil)
log = “#{configuration.deploy_to}/revisions.log”

"(test -e #{log} || touch #{log} && chmod 666 #{log}) && " +
“echo date +\"%Y-%m-%d %H:%M:%S\" $USER #{configuration.revision}
#{directory} >> #{log};”

So, stuck on this idea that the " are the problem, I took them out:

def logging_commands(directory = nil)
log = “#{configuration.deploy_to}/revisions.log”

“(test -e #{log} || touch #{log} && chmod 666 #{log}) && " +
'echo date +"%Y-%m-%d %H:%M:%S"’ + " $USER #{configuration.revision}
#{directory} >> #{log};”

Yet, when I run “cap deploy” in Terminal, I get:

in process!': command "if [[ ! -d /Users/www/myappnamehere/releases/20060517142841 ]]; then\\\n svn co --username josh -q -r741 http://mysvnserver/myappnamehere/Users/www/myappnamehere/releases/20060517142841 &&\\\n (test -e /Users/www/myappnamehere/revisions.log || touch /Users/www/myappnamehere/revisions.log && chmod 666 /Users/www/myappnamehere/revisions.log) && echodate +"%Y-%m-%d
%H:%M:%S"` $USER 741 20060517142841 >>
/Users/www/myappnamehere/revisions.log;\\n fi" failed on
myserver (RuntimeError)

That is, the " are back! So, the logging_commands seem to get escaped
somewhere - it’s not clear to me whether they get escaped in the error
logger, or in the command processor…

Oh: And I can run
echo date +"%Y-%m-%d %H:%M:%S" test1 test2 test3 >> test.log;

on the server without problems.

What am I missing?


“(test -e #{log} || touch #{log} && chmod 666 #{log}) && " +
'echo date +"%Y-%m-%d %H:%M:%S"’ + " $USER #{configuration.revision}
#{directory} >> #{log};”

What happens if you remove the slashes the alternate way? i.e.:

"echo date +'%Y-%m-%d %H:%M:%S'"