2

I want to develop WordPress websites locally using Vagrant (Host: Windows 8 64-bit; Guest: Ubuntu 12.04 LTS). I am using Chris Wiegman's Primary Vagrant (an Apache version of VVV)

I got it working, but as soon as I added all my files the site ran incredibly slow. After research I'm guessing this is down to shared folders being slow. The work around as mention in this blog post on the Vagrant website, is to use rsync.

Despite their being no instructions on how to get rsync working on Windows, I came across this article which recommends the free version of cwrsync. I also had to add the path environmental variable so that rsync worked across all folders on Windows (this answer helped with this)

I edited the vagrant file so that rsync would be used by appending ,"rsync", rsync__exclude: ".git/" to the Primary Vagrant vagrant file:

config.vm.synced_folder "sites/stable.wordpress.vagrant", "/var/www/stable.wordpress.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/stable.wordpress.vagrant/uploads", "/var/www/stable.wordpress.vagrant/wordpress/wp-content/uploads", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/trunk.wordpress.vagrant", "/var/www/trunk.wordpress.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/trunk.wordpress.vagrant/uploads", "/var/www/trunk.wordpress.vagrant/wordpress/wp-content/uploads", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/Search-Replace-DB", "/var/www/replacedb.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/phpmyadmin", "/var/www/phpmyadmin.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/webgrind", "/var/www/webgrind.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"

Then I did a vagrant up --provision. But unfortunately I am getting the following error messages. Despite trying to find the issue online, I can't.

Here are the error messages:

==> default: Rsyncing folder: /cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites
/stable.wordpress.vagrant/ => /var/www/stable.wordpress.vagrant
==> default:   - Exclude: [".vagrant/", ".git/"]
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites/stable.wordpress.v
agrant/
Guest path: /var/www/stable.wordpress.vagrant
Command: rsync --verbose --archive --delete -z --chmod=ugo=rwX --no-perms -e ssh -p 2222 -o StrictHostKeyChecking=no -i
'C:/Users/IanAnderson/.vagrant.d/insecure_private_key' --exclude .vagrant/ --exclude .git/ /cygdrive/c/Users/IanAnderson
/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites/stable.wordpress.vagrant/ vagrant@127.0.0.1:/var/www/stabl
e.wordpress.vagrant
Error: Warning: Permanently added '[127.0.0.1]:2222' (RSA) to the list of known hosts.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(759) [sender=3.0.6]
Community
  • 1
  • 1
iagdotme
  • 1,033
  • 2
  • 21
  • 38
  • 1
    It looks like you are using Cygwin? If so, reinstall cygwin and select the rsync and ssh packages when you go through the setup. I was unable to get vagrant to work with cwrsync, but it was very quick through cygwin's rsync. – littleforest May 08 '14 at 00:28
  • @littleforest do you perhaps know of a good way to get it working? I am using docker with cagrant and want to use rsync to share the folders. Unfortunately vagrant can't find my rsync – We0 Aug 13 '14 at 14:38
  • @We0 I don't have any experience with running Vagrant with cagrant or docker. Is your rsync executable in your Windows PATH variable? – littleforest Aug 18 '14 at 18:15
  • I actually got it working, I had to run in Cygwin where my rsync works, but thanks for your reply! – We0 Aug 19 '14 at 08:34
  • @We0 What shell are you using? Sounds like your $env:PATH (Powershell) environment variable does not have \bin on it. FWIW, we use a script similar to https://gist.github.com/mefellows/80b05f8af9fd9f526ec5 to bootstrap the windows box automatically. – Matthew Fellows Dec 17 '14 at 00:54
  • @littleforest You're awesome. I've been stuck on this for a week. cwRsync is a mess. Cygwin with rsync and openssh did magic! – StalkAlex Nov 17 '15 at 04:53

4 Answers4

0

Try using MinGW. It brings its own ssh.exe in /bin and rsync.exe in /msys/<version_number>/bin. Adding these directories to my PATH made it work on my machine.

Sebastian
  • 13
  • 5
  • I stumbled into this the other day ... MinGW uses a stone age version of openssh while git for windows uses a fairly modern version of it. Unfortunately the rsync client is not included with wingit and the one with MinGW doesn't like the newer ssh client. Tweaking the path is about the only option. – Dave G Jul 31 '16 at 11:20
0

Adding to Sebastian Kliem's answer: for me it was necessary to add the MinGW /bin directory to the start of my PATH. I got the error you mentioned when using git's ssh with MinGW's rsync. Putting MinGW at the start made sure the two worked well together.

Izak Marais
  • 131
  • 4
0

This is no rsync solution, but it works for sharing files to a windows host with better performace than regular virtual box shares.

I successfully used this plugin which starts a nfs daemon on windows: https://github.com/winnfsd/vagrant-winnfsd

I haven't tested it thoroughly because it is a work in progress and first time supporting windows on my project. It seems to do the trick and performs decently so far. Haven't tried it with MySQL data shared onto the host, which was the slowest resource of the server stack.

Also, i use it along the vagrant-bindfs plugin to route the user uid/gid. This probably ads overhead to the mix though but automates the whole process.

0

I know this question is older than the issue, but in case this might help someone: there is a known issue with Vagrant >=1.8.0 and Windows hosts that triggers this kind of error messages.

To prevent this, try removing the following lines (77 to 79) in $VAGRANT_HOME\embedded\gems\gems\vagrant-1.8.0\plugins\synced_folders\rsync\helper.rb :

"-o ControlMaster=auto " +
"-o ControlPath=#{controlpath} " +
"-o ControlPersist=10m " +

Source

Tan
  • 221
  • 1
  • 7