Skip to content
This repository was archived by the owner on Feb 11, 2022. It is now read-only.

Commit a0f5806

Browse files
committed
Merge pull request #77 from tknerr/fix-rsync-on-windows
Fix rsync on windows (alternative)
2 parents f5a72bc + 228386f commit a0f5806

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/vagrant-aws/action/sync_folders.rb

+18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
require "vagrant/util/scoped_hash_override"
66

7+
require "vagrant/util/which"
8+
79
module VagrantPlugins
810
module AWS
911
module Action
@@ -28,13 +30,23 @@ def call(env)
2830
# Ignore disabled shared folders
2931
next if data[:disabled]
3032

33+
unless Vagrant::Util::Which.which('rsync')
34+
env[:ui].warn(I18n.t('vagrant_aws.rsync_not_found_warning'))
35+
break
36+
end
37+
3138
hostpath = File.expand_path(data[:hostpath], env[:root_path])
3239
guestpath = data[:guestpath]
3340

3441
# Make sure there is a trailing slash on the host path to
3542
# avoid creating an additional directory with rsync
3643
hostpath = "#{hostpath}/" if hostpath !~ /\/$/
3744

45+
# on windows rsync.exe requires cygdrive-style paths
46+
if Vagrant::Util::Platform.windows?
47+
hostpath = hostpath.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
48+
end
49+
3850
env[:ui].info(I18n.t("vagrant_aws.rsync_folder",
3951
:hostpath => hostpath,
4052
:guestpath => guestpath))
@@ -63,6 +75,12 @@ def call(env)
6375
hostpath,
6476
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
6577

78+
# we need to fix permissions when using rsync.exe on windows, see
79+
# http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
80+
if Vagrant::Util::Platform.windows?
81+
command.insert(1, "--chmod", "ugo=rwX")
82+
end
83+
6684
r = Vagrant::Util::Subprocess.execute(*command)
6785
if r.exit_code != 0
6886
raise Errors::RsyncError,

locales/en.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ en:
1616
Instance is not created. Please run `vagrant up` first.
1717
ready: |-
1818
Machine is booted and ready for use!
19+
rsync_not_found_warning: |-
20+
Warning! Folder sync disabled because the rsync binary is missing.
21+
Make sure rsync is installed and the binary can be found in the PATH.
1922
rsync_folder: |-
2023
Rsyncing folder: %{hostpath} => %{guestpath}
2124
starting: |-

0 commit comments

Comments
 (0)