Question

I want to use Grunt and rsync deploy some code from my computer (Windows) to a server (Linux).

My Gruntfile.js is

module.exports = function(grunt) {

    grunt.initConfig({

        rsync: {
            options: {
                args: ['--verbose', '--chmod=777'],
                exclude: ['*.git', 'node_modules'],
                recursive: true
            },
            production: {
                options: {
                    src: './bitzl.com',
                    dest: '/home/marcus/bitzl.com',
                    host: 'marcus@bitzl.com',
                    syncDest: true
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-rsync');
}

Please note that I use the homedirectory of marcus and chmod=777 just to simplify testing.

Running grunt rsync fails:

Running "rsync:production" (rsync) task
rsyncing ./example.com >>> /home/marcus/bitzl.com
Shell command was: rsync ./bitzl.com marcus@bitzl.com:/home/marcus/bitzl.com --rsh ssh --recursive --delete --delete-exc
luded --exclude=*.git --exclude=node_modules --verbose --chmod=777
ERROR
Error: rsync exited with code 12
Warning: Task "rsync:production" failed. Use --force to continue.
Error: Task "rsync:production" failed.
    at Task.<anonymous> (D:\git\bitzl.com\node_modules\grunt\lib\util\task.js:200:15)
    at null._onTimeout (D:\git\bitzl.com\node_modules\grunt\lib\util\task.js:236:33)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Aborted due to warnings.

However, running the rsync command from above without Grunt works fine:

rsync ./bitzl.com marcus@bitzl.com:/home/marcus/bitzl.com --rsh ssh --recursive --delete --delete-excluded --exclude=*.git --exclude=node_modules --verbose --chmod=777

Rsync promts for the passphrase of my public key (via Grunt it doesn't) and syncs like a breeze.

Authentication on the server works via public key (with passphrase). Password authentication would be fine, too.

My guess is that somehow the password promt breaks and rsync fails with a protocol error (that's exit code 12).

What I am missing to get grunt-rsync working on Windows?

Update:

From a Linux VM (Ubuntu 12.04 via Virtualbox/Vagrant) it works like on would expect.

Was it helpful?

Solution

It turned out as a bug in grunt-rsync. A pull request I've filled in for rsyncwrapper has been accepted, and with the recent version of grunt-rsync everything works as expected.

If you still experience problems, make sure you have at least grunt-rsync version 0.6.0 installed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top