diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index 9a88a90dc..83820f5e5 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -50,20 +50,15 @@ module Vagrant end end - # This takes any path and converts it to a full-length Windows - # path on Windows machines in Cygwin. + # This takes any path and converts it from a Windows path to a + # Cygwin or msys style path. # + # @param [String] path # @return [String] - def cygwin_windows_path(path, **opts) - return path if !cygwin? && !opts[:force] - - # First, no matter what process we use below, we must replace - # all "\" with "/", otherwise cygpath doesn't work. - path = path.gsub("\\", "/") - + def cygwin_path(path) begin # First try the real cygpath - process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s) + process = Subprocess.execute("cygpath", "-u", "-a", path.to_s) return process.stdout.chomp rescue Errors::CommandUnavailableWindows # Sometimes cygpath isn't available (msys). Instead, do what we @@ -77,6 +72,21 @@ module Vagrant end end + # This takes any path and converts it to a full-length Windows + # path on Windows machines in Cygwin. + # + # @return [String] + def cygwin_windows_path(path) + return path if !cygwin? + + # Replace all "\" with "/", otherwise cygpath doesn't work. + path = path.gsub("\\", "/") + + # Call out to cygpath and gather the result + process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s) + return process.stdout.chomp + end + # This checks if the filesystem is case sensitive. This is not a # 100% correct check, since it is possible that the temporary # directory runs a different filesystem than the root directory. diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index 8c739e67b..ab74a60a3 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -14,9 +14,8 @@ module VagrantPlugins hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s if Vagrant::Util::Platform.windows? - # rsync for Windows expects cygwin style paths - hostpath = Vagrant::Util::Platform.cygwin_windows_path( - hostpath, force: true) + # rsync for Windows expects cygwin style paths, always. + hostpath = Vagrant::Util::Platform.cygwin_path(hostpath) end # Make sure the host path ends with a "/" to avoid creating