hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.3k stars 4.44k forks source link

Rsync on Windows using cwRsync fails with No such file or directory (2) #3230

Closed balajisivaraman closed 10 years ago

balajisivaraman commented 10 years ago

Hi,

I am trying to set up an Rsync share on a Windows 8 machine with a Ubuntu 12.04 LTS Guest VM, and it fails with the following error.

Balaji@GANESHA-PC /c/Coding/Ruby/discourse (master)
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'discourse-0.9.7'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: discourse_default_1394892063920_77253
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 3000 => 4000 (adapter 1)
    default: 1080 => 4080 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Error: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 4.3
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /c/Coding/Ruby/discourse/ => /vagrant
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /c/Coding/Ruby/discourse/
Guest path: /vagrant
Command: rsync --verbose --archive --delete -z -e ssh -p 2222 -o StrictHostKeyChecking=no -i 'C:/Users/Balaji/.vagrant.d/insecure_private_key' --exclude .vagrant/ /c/Coding/Ruby/discourse/ vagrant@127.0.0.1:/vagrant
Error: rsync: change_dir "/c/Coding/Ruby/discourse" failed: No such file or directory (2)
FATAL I/O ERROR: dying to avoid a --delete-during issue with a pre-3.0.7 receiver.
rsync error: requested action not supported (code 4) at flist.c(1882) [sender=3.1.0]

I am using cwRsync version 3.1.0 downloaded from the following location: https://www.itefix.no/download/cwRsync_5.2.2_Free.zip

I am running this in a Git Bash window with Administrative Privileges. My user is also the owner of the directory being shared, so I doubt whether it could be an issue where I don't have enough privileges.

The Rsync version in the Guest is 3.0.9. At first, I thought that was the issue. But even if I manually install 3.1.0 from source, I am getting the same error.

Any advice? Thanks in advance.

kylemacfarlane commented 10 years ago

I had these problems yesterday.

1) First you need to upgrade rsync on the virtual machine to avoid the issue with --delete-during. After installing 3.1.0 from source make sure you reboot the guest or clear the path cache.

2) 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.

balajisivaraman commented 10 years ago

@kylemacfarlane Thanks! Works like a charm!

brianreavis commented 10 years ago

@balajisi Can we reopen this? This is still an issue on 1.6.3 (and shouldn't have to be fixed by editing the vagrant source).

https://github.com/mitchellh/vagrant/blob/master/plugins/synced_folders/rsync/helper.rb#L43

francislavoie commented 10 years ago

+1, this should be re-opened. I had to make this change as well to get rsync working.

kriserickson commented 10 years ago

Also having this problem in 1.6.3. I found that platform.rb wasn't detecting cygwin, so switching to see if ENV path contained cygwin fixed it, but this a pretty bad hack.

gitTrusty commented 10 years ago

+1, re-open please. Also having this problem in 1.6.3. I had to make this change to get rsync working.

kellyselden commented 10 years ago

It now needs to be applied on line 43: hostpath = "/cygdrive" + Vagrant::Util::Platform.cygwin_path(hostpath)

francislavoie commented 10 years ago

I think someone should probably make a new issue, this won't get any attention since it's already closed.

brianreavis commented 10 years ago

@francislavoie I think you're right. One final attempt: @mitchellh Re-open?

machek commented 10 years ago

same problem and "/cygdrive" + helped, should be fixed

starrychloe commented 10 years ago

Version 1.5.4 worked, but version 1.6.3 broke. It treats c:\Users as /c/Users, which doesn't work on Windows. It should use the colon: c:/Users. (Wait - should not use colon. Every other Cygwin binary is tolerant of c: except rsync, which treats it as host:path. Use /cygdrive/c/path instead.)

==> default: Rsyncing folder: /c/Users/Chloe/Documents/ODesk/AIDC/BK-Development/ => /rsync/BK-Development
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /c/Users/Chloe/Documents/ODesk/AIDC/BK-Development/
Guest path: /rsync/BK-Development
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 StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i 'C:/Users/Chloe/.vagrant.d/insecure_private_key' --exclude .vagrant/ /c/Users/Chloe/Documents/ODesk/AIDC/BK-Development/ vagrant@127.0.0.1:/rsync/BK-Development
Error: Warning: Permanently added '[127.0.0.1]:2222' (RSA) to the list of known hosts.
rsync: change_dir "/c/Users/Chloe/Documents/ODesk/AIDC/BK-Development" failed: No such file or directory (2)
FATAL I/O ERROR: dying to avoid a --delete-during issue with a pre-3.0.7 receiver.
rsync error: requested action not supported (code 4) at /home/lapo/package/rsync-3.0.9-1/src/rsync-3.0.9/flist.c(1800) [sender=3.0.9]
francislavoie commented 10 years ago

That's not the problem. Cygwin uses unix style paths and mounts the C drive in it's own /cygdrive directory. The path /cygdrive/c/users is the correct path when using cygwin.

nomasprime commented 10 years ago

+1

ckatzorke commented 10 years ago

+1

mickdelaney commented 10 years ago

+1

kriserickson commented 10 years ago

As I briefly stated above (but not very clearly I see) the problem is the test in HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/platform.rb for ENV["VAGRANT_DETECTED_OS"] that no longer properly detects cygwin. VAGRANT_DETECTED_OS is coming from uname. My guess is that is because on a lot of people's system uname is being hijacked by mysgit and coming back as MING32_NT rather than CYGWIN_NT. I fixed this by hacking the test for cygwin to be a test for whether cygwin in the ENV["PATH"] and that seemed to fix my problem, however I don't think it is the appropriate way to check for cygwin but I can submit that patch if people desire.

kylemacfarlane commented 10 years ago

The problem specifically with cwRsync (which this ticket is about) is that it's a standalone version of rsync for Windows and doesn't require Cygwin to be installed. So with a regular standalone cwRsync installation, Cygwin will never be on the PATH and Vagrant will never add the required /cygdrive prefix.

The solution I think is to add a configuration setting that allows users to set their own prefix. Currently Vagrant tries to be smart and detect the environment but it obviously doesn't work reliably.

rarkins commented 10 years ago

+1

khromov commented 10 years ago

+1 same issue

n0v3xx commented 10 years ago

+1 same issue vagrant 1.6.3

JVMartin commented 10 years ago

+1 same here.

Venorcis commented 10 years ago

+1 in vagrant 1.6.3 as well (with cwRsync installed and on PATH)

Changing line 43 in C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.6.3\plugins\synced_folders\rsync\helper.rb to hostpath = "/cygdrive" + Vagrant::Util::Platform.cygwin_path(hostpath) does work though

mdoelker commented 10 years ago

I also had trouble with vagrant not detecting cygwin. After reading @kriserickson 's comment and inspecting the source, manually adding VAGRANT_DETECTED_OS=cygwin to the environment fixed it for me. I'm on Vagrant 1.6.3 with rsync 3.0.9 on both win (via cygwin, non-standalone) and vm. The issue is still valid though, as manually setting this should not be necessary.

kummerer94 commented 10 years ago

I got the newest Vagrant Version installed (1.6.5) and I have the same problem. I have Cygwin and rsync installed.

My output is:

Host path: /cygdrive/c/Users/Alexander/repos/stipnetz/
Guest path: /var/www
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 StrictHos
tKeyChecking=no -o UserKnownHostsFile=/dev/null -i 'C:/Users/Alexander/.vagrant.
d/insecure_private_key' --exclude .vagrant/ /cygdrive/c/Users/Alexander/repos/st
ipnetz/ vagrant@127.0.0.1:/var/www
Error: rsync: Failed to exec ssh: No such file or directory (2)
rsync error: error in IPC code (code 14) at /usr/src/ports/rsync/rsync-3.0.9-1/s
rc/rsync-3.0.9/pipe.c(84) [sender=3.0.9]
rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Broken pip
e (32)
rsync error: error in IPC code (code 14) at /usr/src/ports/rsync/rsync-3.0.9-1/s
rc/rsync-3.0.9/io.c(1532) [sender=3.0.9]

I tried to change live 43 of helper.rb but that did not work for me. The same for adding VAGRANT_DETECTED_OS = "cygwin"to my Vagrantfile.

mdoelker commented 10 years ago

@kummerer94 you seem to be missing SSH which is used by rsync. Install it from network category in Cygwin.

deancsmith commented 10 years ago

+1 still getting this issue on 1.6.5.

walva commented 10 years ago

+1 with 1.6.5

avevlad commented 10 years ago

+1

brunowego commented 10 years ago

+1 with 1.6.5

==> default: Rsyncing folder: /cygdrive/d/Servers/Homestead/www/ => /home/vagran
t/www
Vagrant::Errors::RSyncError: There was an error when attempting to rsync a synce
d folder.
Please inspect the error message below for more info.

Host path: /cygdrive/d/Servers/Homestead/www/
Guest path: /home/vagrant/www
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 StrictHos
tKeyChecking=no -o UserKnownHostsFile=/dev/null -i 'C:/Users/bruno/.vagrant.d/in
secure_private_key' --exclude .vagrant/ /cygdrive/d/Servers/Homestead/www/ vagra
nt@127.0.0.1:/home/vagrant/www
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(226) [Receive
r=3.1.0]
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]
KMantas commented 10 years ago

https://github.com/mitchellh/vagrant/issues/3230#issuecomment-54082977

fixes for 1.6.5

brunowego commented 10 years ago

Works for me:

  1. Install Cygwin
  2. Instal rsync package: apt-cyg install rsync
  3. Changing line 43 in C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.6.X\plugins\synced_folders\rsync\helper.rb to hostpath = "/cygdrive" + Vagrant::Util::Platform.cygwin_path(hostpath)

Thanks @Venorcis.

shihshen commented 10 years ago

3230 (comment)

doesn't work for me. My environment is: Windows 7 + cwRsync(cwRsync_5.3.0_Free).

Here is the log: Error: rsync: Failed to exec ssh: No such file or directory (2) rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.1pre1] rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.1pre1]

osroot25 commented 10 years ago

Editing the libraries is always the last way, but I found another way, local in your Vagrantfile!

helping vagrant by giving it the (modified but right) ENV["VAGRANT_DETECTED_OS"] just solves the problem: in vagrantfile, have a line

ENV["VAGRANT_DETECTED_OS"] = ENV["VAGRANT_DETECTED_OS"].to_s + " cygwin" then, in the libraries, /cygdrive/ is added to the path

stevelove commented 10 years ago

@osroot25: Thanks for suggesting the Vagrantfile workaround. That solved it for me.

willmorgan commented 9 years ago

This is still an issue for me, sadly!

Windows 8.1, cwRsync, CentOS guest, Vagrant 1.6.5.

Had to mess with my Vagrantfile in the end. Many thanks to @osroot25 for the relatively elegant workaround.

osroot25 commented 9 years ago

and again, please check out https://github.com/mitchellh/vagrant-installers/issues/49 , I think I have pinpointed the source of the problem, but that project hasn't many watchers, the please spread this around to the right people

ortix commented 9 years ago

+1

jakul commented 9 years ago

@osroot25 +1 thanks for the workaround!

fresheneesz commented 9 years ago

+1

sveri commented 9 years ago

+1

mmodler commented 9 years ago

+1

fletchowns commented 9 years ago

+1

The vagrantfile workaround worked for me in msysgit but I also have cygwin installed, which is where it's getting rsync from:

Welcome to Git (version 1.9.4-preview20140611)

$ which rsync
/c/cygwin64/bin/rsync
iamsteveholmes commented 9 years ago

None of the Vagrant workarounds seem to work for me. I'm on 32 bit cygwin and windows 7.

NathanielMichael commented 9 years ago

+1 Editing the library worked for me.

The machine I'm testing with has Cygwin installed but last on the PATH (just for rsync). Mainly using Git Bash + Cmder, so it's not detected as Cygwin properly.

Is there a way to test the rsync binary directly to determine if it's a Cygwin distributed binary? That may be the best option to support as many configurations as possible.

chrisg123 commented 9 years ago

@osroot25 's solution works, however if you also use windows cmd for vagrant calls (ex. I run a script in phpstorm that uses windows cmd) then you should add your cygwin bin file to your %PATH% variables. Otherwise you will get errors like:

The executable 'cygpath' Vagrant is trying to run was not found in the %PATH% variable. This is an error. Please verify this software is installed and on the path.

VagrantFile

    Vagrant.configure(2) do |config|
      ... your own config...etc.

            ENV["VAGRANT_DETECTED_OS"] = ENV["VAGRANT_DETECTED_OS"].to_s + " cygwin"

    end
jamesvl commented 9 years ago

For some reason it doesn't work for me - editing the Vagrantfile to modify ENV never made it to the helper or plugin scripts in Vagrant, both in vagrant up or vagrant rsync.

I traced through the code; even though cygwin_path() is getting called in platform.rb (since my platform comes back as "mingw32"), it uses the alternate bash script to detect the path, which leaves off the necessary /cygdrive prefix (~ line 74).

I ended up adding an additional check in cygwin? using an ENV variable that was set properly: TERM.

Edit: embedded\gems\gems\vagrant-1.7.3\lib\vagrant\util\platform.rb on line 16 (Vagrant 1.7.3):

return true if ENV["TERM"] &&
  ENV["TERM"].downcase.include?("cygwin")

After this, the vagrant commands up, rsync, and rsync-auto all work as expected for me.

AnthonyMastrean commented 9 years ago

@jamesvl Only the MSYS or Git Bash terminal reports its TERM as cygwin. What about native Windows consoles, where Vagrant should also work, like cmd.exe and PowerShell?

lucassch commented 9 years ago

Works for me:

Install Cygwin Instal rsync package: apt-cyg install rsync Changing line 43 in C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.6.X\plugins\synced_folders\rsync\helper.rb to hostpath = "/cygdrive" + Vagrant::Util::Platform.cygwin_path(hostpath) Thanks @Venorcis.

Works for me too! Thanks @Venorcis @brunowego

AnthonyMastrean commented 9 years ago

We still need a solution that works without cygwin on Windows. i'm putting together some info now. Will post later.

GBuella commented 9 years ago

Hi, just a note: An easier way to set VAGRANT_DETECTED_OS is to set it as an environment variable in cygwin, this worked for me:

VAGRANT_DETECTED_OS=cygwin vagrant up

or if needed, place it in your bash startup file .profile, .bashrc in your cygwin home , whatever. This way, things still work with cmd.exe, as the you would only set the environment variable in cygwin.