Topic: capistrano from windows with git and deploy_via copy

I have a problem that capistrano ignores the directory set in :copy_dir

My capistrano setting are the following (besides the usual stuff):

set :deploy_via, :copy
set :copy_dir, "C:/caches/myapp"

The directory C:/caches/myapp exists

I'm running:

C:\myapp>cap deploy
  * executing `deploy'
  * executing `deploy:update'
** transaction: start
  * executing `deploy:update_code'
    executing locally: "git ls-remote ssh:// HEAD"
  * getting (via checkout) revision b6f590f2d59b3f6ae14e1f5278512f7f1b4edd1a to
    executing locally: git clone -q ssh:// C:\caches\\20100312233007 && cd /D C:\caches\\20100312233007 && git checkout -q -b deploy b6f590f2d59b3f6ae14e1f5278512f7f1b
warning: Remote branch deploy not found in upstream origin, using HEAD instead
  * processing exclusions...
*** [deploy:update_code] rolling back


(and a whole bunch of errors)

Even though I specify the directory where to place a copy (to where clone the repository), I still have the repository cloned into my current directory C:\myapp as if the output directory is not specified in git clone. Then I get errors because capistrano tried to deploy from a non-existing directory C:\caches\\20100312233007.

However if I manually run
git clone -q ssh:// C:\caches\\20100312233007

it places the copy into the correct directory.

It either doesn't make the command right (even though printing it out right) or may be silently fails to create a new directory. Any ideas?

The capistrano version is 2.5.17

After I switched to the latest version of git, "git clone" started to crash with a "Too many arguments" error.

Last edited by whiterabbit (2010-03-25 18:07:44)

Re: capistrano from windows with git and deploy_via copy

I have solved it.

Apparently, it's a ruby + git clone (+ windows?) issue.

If I chain commands with && while calling system(cmd) from ruby, chaining "git clone" with other commands is not fine. Git clone perceives the chained commands as its own continuation, i.e. as a destination directory, unless I run it from the command line.

As I couldn't find any references or solutions to this problem on the internet, I put a hack to capistrano code, so "git clone" is executed separately.

In <ruby directory>\lib\ruby\gems\1.8\gems\capistrano-2.5.18\lib\capistrano\recipes\deploy\strategy\base.rb after the line 53 (cmd = cmd.split...)
add the following lines:

if cmd =~ /\s\&\&\s/ && cmd =~ /^git\s+clone/
   cmd1, cmd = cmd.split(" && ", 2)

it checks if it's a chained command and the first command is "git clone", and if such it executes it separately. It may not work for all possible cases.

Last edited by whiterabbit (2010-03-18 18:55:06)