Deploying to linode via capistrano using git on a windows machine

I am trying to deploy via capistrano and git on a windows machine without much success. I run into the ‘Too many arguments error’. Someone else had a similar problem and posted a solution in 2010 but this fix is not working for me. It is set to deploy from local machine through “set :deploy_via, :copy”.

Here is the detailed error message:

$ cap staging deploy
   triggering load callbacks
 * executing `staging'
   triggering start callbacks for `deploy'
 * executing `multistage:ensure'
 * executing `uploads:register_dirs'
 * executing `deploy'
 * executing `deploy:update'
** transaction: start
 * executing `deploy:update_code'
   executing locally: "git ls-remote git@github.com:username/_app.git deve lopment"
   command finished in 2408ms
 * getting (via checkout) revision 121e566c349a1406cba1936abeda49109de7fd78 to C:/Users/myname/AppData/Local/Temp/20120329203009
   executing locally: git clone git@github.com:user/_app.git C:/Users/ username/AppData/Local/Temp/20120329203009 && cd C:/Users/username/AppData/Local/Temp/ 20120329203009 && git checkout -b deploy 121e566c349a1406cba1936abeda49109de7fd7
   8 Too many arguments.

Any idea what I am doing wrong?

  • Heroku git repository
  • Removing SVN username and password from Eclipse does not work in Windows 7
  • Run git commands from a C# function
  • Git on windows : “I don't handle protocol 'git clone http'”
  • .gitignore fails to ignore a file
  • Best practices for a single developer webproject setup
  • Git push origin master returns Error cannot spawn … why?
  • Git for Windows doesn't know %USERPROFILE%
  • One Solution collect form web for “Deploying to linode via capistrano using git on a windows machine”

    Well, I’m in the same case.

    What I’ve found is that my Windows 7 64 bits is recognized as a different RUBY_PLATFORM than the planned case.
    Mine is the ‘i386-mingw32’ RUBY_PLATFORM.

    If you read the ‘base.rb’ around line 53, there is the condition

    if 'RUBY_PLATFORM =~ /win32/'
    

    So, in my case, it don’t succeed. I change the line like it :

    if 'RUBY_PLATFORM =~ /win32/' || RUBY_PLATFORM =~ /i386-mingw32/
    

    And it’s fine.

    I’ve kept the code written by Railsblogger. (with an update for displaying execution time)

    So, now, it’s like that :

          # A wrapper for Kernel#system that logs the command being executed.
          def system(*args)
            cmd = args.join(' ')
            result = nil
            if RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /i386-mingw32/
              cmd = cmd.split(/\s+/).collect {|w| w.match(/^[\w+]+:\/\//) ? w : w.gsub('/', '\\') }.join(' ') # Split command by spaces, change / by \\ unless element is a some+thing://
    
              # code from http://lifeisrails.wordpress.com/2010/03/25/capistrano-deploy_via-copy-from-gitwindows/
              if cmd =~ /\s&&\s/ && cmd =~ /^git\s+clone/
                cmd1, cmd = cmd.split(" && ", 2)
                logger.trace "executing locally: #{cmd1}"
                elapsed = Benchmark.realtime do
                    result = super(cmd1)
                end
                logger.trace "command finished in #{(elapsed * 1000).round}ms"
                result
              end
    
              cmd.gsub!(/^cd /,'cd /D ') # Replace cd with cd /D
              cmd.gsub!(/&& cd /,'&& cd /D ') # Replace cd with cd /D
              logger.trace "executing locally: #{cmd}"
              elapsed = Benchmark.realtime do
                result = super(cmd)
              end
            else
              logger.trace "executing locally: #{cmd}"
              elapsed = Benchmark.realtime do
                result = super
              end
            end
    

    Hope it will help !!

    Tell me if it works for you ?

    And… if it’s not ok, you could test to display your ‘RUBY_PLATFORM’, by adding a line before the condition like

    logger.trace RUBY_PLATFORM
    
    Git Baby is a git and github fan, let's start git clone.