Vagrant: Rsync fails on Windows with permission denied

Created on 18 Mar 2014  路  6Comments  路  Source: hashicorp/vagrant

It seems that this is because rsync on Windows is trying to copy NTFS file permissions into the virtual machine, ending up with no permissions at all. Its explained further in http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions

As a temporary workaround I have added:

"--chmod=ugo=rwX",

into <Vagrant>\embedded\gems\gems\vagrant-1.5.1\plugins\synced_folders\rsync\helper.rb just after the line saying "-e", rsh,, but obviously this isn't a permanent solution.

The full error is given below:

==> default: Rsyncing folder: /cygdrive/d/Projects/server/ => /vagrant
==> default:   - Exclude: [".vagrant/", ".git/", "app/bootstrap.php.cache", "app/cache/", "vendor/", "build/", "web/bundles/", "web/css/", "web/js/", "web/build.js", "app/logs/", ".idea"]
There was an error when attempting to rsync a synced folder. Please inspect the error message below for more info.

Host path: /cygdrive/d/Projects/server/
Guest path: /vagrant
Command: rsync --verbose --archive --delete -z -e ssh -p 2200 -o StrictHostKeyChecking=no -i 'C:/Users/Dave/.vagrant.d/insecure_private_key' --exclude .vagrant/ --exclude .git/ --exclude app/bootstrap.php.cache --exclude app/cache/ --exclude vendor/ --exclude build/ --exclude web/bundles/ --exclude web/css/ --exclude web/js/ --exclude web/build.js --exclude app/logs/ --exclude .idea /cygdrive/d/Projects/Playpearls/bitcoinliveroulette/server/ [email protected]:/vagrant
Error: rsync: failed to modify permissions on "/vagrant/.": Permission denied (13)
rsync: opendir "/vagrant/." failed: Permission denied (13)
rsync: recv_generator: failed to stat "/vagrant/.gitignore": Permission denied (13)
rsync: recv_generator: failed to stat "/vagrant/.travis.yml": Permission denied (13)
rsync: recv_generator: failed to stat "/vagrant/composer.json": Permission denied (13)
rsync: recv_generator: failed to stat "/vagrant/composer.lock": Permission denied (13)
rsync: recv_generator: mkdir "/vagrant/app" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
rsync: recv_generator: mkdir "/vagrant/bin" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
rsync: recv_generator: mkdir "/vagrant/src" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
rsync: recv_generator: mkdir "/vagrant/web" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1165) [sender=3.1.0]

Most helpful comment

I just encountered this - Fresh Win7 (with cygwin for rsync).
Tried applying same changes mitchell referenced in helper file as well as (separately) the mount options and rsync__args listed above.

Both showed the --chmod=ug=rwX,o=rxX addition to the rsync command but kept the permission denied error.

All 6 comments

When playing around with the rsync implementation I also experienced this error but I got it working somehow. I believe the :mount_options settings were helping but I'm not sure.

You could try it:

I have added rsync__args: ["--chmod=ug=rwX,o=rxX"] and now it works

Hm, so is the solution here for Vagrant to automatically do this on Windows hosts, you think?

I'm using the latest cygwin x64 binaries of rsync and ssh and I can verify the same issue as @ccapndave .

The solution for me was to add
:rsync__args => ["--chmod=ugo=rwX","--verbose", "--archive", "--delete", "-z"]

@mitchellh It makes sense to make this the default for Windows. Currently you can override the default arguments if you needed to adjust the permissions to your own needs. +1 for default Windows behavior.

Done. Fixed

I just encountered this - Fresh Win7 (with cygwin for rsync).
Tried applying same changes mitchell referenced in helper file as well as (separately) the mount options and rsync__args listed above.

Both showed the --chmod=ug=rwX,o=rxX addition to the rsync command but kept the permission denied error.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lebogan picture lebogan  路  3Comments

hesco picture hesco  路  3Comments

rhencke picture rhencke  路  3Comments

Cbeck527 picture Cbeck527  路  3Comments

DreadPirateShawn picture DreadPirateShawn  路  3Comments