Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Rsync 3.0.9 to work on Vagrant VM box through Cygwin on windows 7

My vagrant VM box is super slow when I try to run my Rails app on it, and I'm guessing it's due to the shared folder problem.

I am trying to use rsync to circumvent the problem. I installed Cygwin and necessary packages, put C:\cygwin64\bin; as PATH environment variable and then changed my Vagrantfile to config.vm.synced_folder ".", "/vagrant", type: "rsync"

When I run vagrant up, I Get this error message

$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... "rsync" could not be found on your PATH. Make sure that rsync is properly installed on your system and available on the PATH.

What's going wrong here? Thank you so much ... if there's any other way to run Vagrant VM box smoothly and faster on Windows 7, I would love to hear it too.

like image 553
Terry Bu Avatar asked Jun 09 '14 19:06

Terry Bu


1 Answers

This turned out to be a bunch of brick-walls you have to circumvent when installing Rsync and setting it up correctly for Vagrant on Windows 7.

First of all, the error "rsync" could not be found on your PATH. Make sure that rsync is properly installed on your system and available on the PATH. was due to the fact that

1) Environment variable for Cygwin was placed in the latest order in the PATH, I changed it to the beginning of the path

2) During installation of Cygwin and Rsync, I installed individual "subpackages" instead of installing everything, thinking that it would be okay. Turns out I was wrong. I installed everything in the Admin package and Net package (not the SRC but just the bins), and then it started working. I suggest you set-up Cygwin again and really try to download everything if you see that error. (I found these solutions through this post on SO cygwin + rsync)

Now, I could go into CMD and type rsync, and it would show up correctly. But then when I ran vagrant up it gave me another error saying

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

Host path: /c/Users/xxxxx 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 StrictHostKeyCh /c/Users/xxxx / [email protected]:/vagrant Error: cygwin warning: MS-DOS style path detected: C:/Users/xxxxxxx Preferred POSIX equivalent is: /cygdrive/c/Users/xxxx CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts. rsync: change_dir "/c/Users/xxxxxxx" failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at /usr/src/ports/rsync/rsync-3.0.9-1/src/rsync-3.0.9/main.c(1052) [sender=3.0.9]

I googled solution to this error and found this site. https://github.com/mitchellh/vagrant/issues/3230

Then there's a bug with Vagrant and cwrsync that I mentioned in #3086. For now, just edit C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.5.1\plugins\synced_folders\rsync\helper.rb and add hostpath = "/cygdrive" + hostpath to line 74. It's a terrible solution but quick and simple.

Editing that helper.rb file and adding hostpath at line 74 (just made some blank lines right there and pasted it in) and now it works perfectly!!!!

Rsync makes the shared folder soooooo much faster on Rails!!!! I think it is worth the pain of setting it up correctly. Try it!!

like image 164
Terry Bu Avatar answered Sep 28 '22 06:09

Terry Bu