如何在Windows中与Vagrant同步文件夹?

时间:2017-05-25 01:28:18

标签: windows vagrant

在Windows 10上使用Vagrant 1.9.2。

chololatey安装了rsync:

C:\> choco install rsync

Vagrantfile

Vagrant.configure("2") do |config|
  ...
  config.vm.synced_folder "data", "/vagrant"
  ...
end

此处想要将当前路径下的data文件夹同步到Vagrant中的/vagrant路径。登录Vagrant并在test路径下创建/vagrant文件时,请检查Windows data文件夹中没有任何内容。所以文件没有同步。为什么?如何同步?

修改

今天开始流浪,得到了新的问题:

There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /c/Users/me/data/
Guest path: /vagrant
Command: "rsync" "--verbose" "--archive" "--delete" "-z" "--copy-links" "--chmod=ugo=rwX" "--no-perms" "--no-owner" "--no-group" "--rsync-path" "sudo rsync" "-e" "ssh -p 2222 -o LogLevel=FATAL   -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i 'C:/Users/me/.vagrant/machines/default/virtualbox/private_key'" "--exclude" ".vagrant/" "/c/Users/me/data/" "vagrant@127.0.0.1:/vagrant"
Error: rsync: change_dir "/c/Users/me/data" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]

1 个答案:

答案 0 :(得分:1)

我使用nfs类型来解决问题:

config.vm.synced_folder "data", "/vagrant", type: "nfs"