Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
balajisivaraman opened this issue Mar 15, 2014 · 67 comments
Closed

Comments

@balajisivaraman
Copy link

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
Copy link

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 vagrant rsync on windows #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
Copy link
Author

@kylemacfarlane Thanks! Works like a charm!

@brianreavis
Copy link

@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
Copy link

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

@kriserickson
Copy link

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
Copy link

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

@kellyselden
Copy link

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

@francislavoie
Copy link

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

@brianreavis
Copy link

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

@machek
Copy link

machek commented Jun 20, 2014

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

@starrychloe
Copy link

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
Copy link

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
Copy link

+1

2 similar comments
@ckatzorke
Copy link

+1

@mickdelaney
Copy link

+1

@kriserickson
Copy link

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
Copy link

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
Copy link

rarkins commented Jul 21, 2014

+1

@khromov
Copy link

khromov commented Jul 27, 2014

+1 same issue

@n0v3xx
Copy link

n0v3xx commented Aug 15, 2014

+1 same issue vagrant 1.6.3

@JVMartin
Copy link

+1 same here.

@Venorcis
Copy link

Venorcis commented Sep 1, 2014

+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
Copy link

mdoelker commented Sep 3, 2014

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
Copy link

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
Copy link

mdoelker commented Sep 6, 2014

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

@deancsmith
Copy link

+1 still getting this issue on 1.6.5.

@chrisg123
Copy link

@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
Copy link

jamesvl commented Jul 14, 2015

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
Copy link

@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
Copy link

lucassch commented Sep 3, 2015

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
Copy link

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

@GBuella
Copy link

GBuella commented Oct 12, 2015

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.

@ccimpoi
Copy link

ccimpoi commented Oct 14, 2015

I have tried cwRsync, MinGW and cygwin on Windows 7.1 and the only way I got rsync working is with cygwin by using the cygwin shell and setting

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

in the Vagrant file.
For me this would go into the Vagrant file because I require each developer to customize these files anyways.

@JaminShanti
Copy link

@BinaryCrafts nice, share your solution with mitchell....

@AnthonyMastrean
Copy link

@JaminShanti cygwin and the cygwin shell are not a solution that I can use and I suspect that others will have the same restriction. For rsync to be fully supported on Windows, it must be possible in any shell.

@hotnuts21
Copy link

Im just trying to get my first ever vagrant box up!

Installed the latest versions of Virtualbox, Vagrant, Putty, and then when i got rsync errors I installed Cygwin with rsync.

have tried both the options here, moved the rsync so it comes before git in the global path and still I get the following error when trying to run vagrant up in a cmd. (with ENV["VAGRANT_DETECTED_OS"] = ENV["VAGRANT_DETECTED_OS"].to_s + " cygwin" in the vagrant file)

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' is up to date...
==> default: Setting the name of the VM: gettingStarted-centos7_default_14507149
03141_9313
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> 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: Warning: Connection timeout. Retrying...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest

default: additions are required for forwarded ports, shared folders, host on

ly
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work prope
rly,
default: in which case you may ignore this message.
==> default: Installing rsync to the VM...
==> default: Rsyncing folder: /cygdrive/c/Users/paul/Projects/gettingStarted-cen
tos7/ => /home/vagrant/sync
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/paul/Projects/gettingStarted-centos7/
Guest path: /home/vagrant/sync
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 IdentitiesOnly=true -o UserKnownHostsFile=/dev/null -i 'C:/Us
ers/paul/Projects/gettingStarted-centos7/.vagrant/machines/default/virtualbox/pr
ivate_key' --exclude .vagrant/ /cygdrive/c/Users/paul/Projects/gettingStarted-ce
ntos7/ vagrant@127.0.0.1:/home/vagrant/sync
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.1]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=
3.1.1]

Any ideas greatly appreciated.

@hotnuts21
Copy link

Fixed my own problem and putting instructions here for anyone else in similar problem. The issue is that SSh is not installed on windows and even though I had installed it via cygwin, it was not set up to run as a service.
Heres a handy guide on getting it running under windows http://www.howtogeek.com/howto/41560/how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/

@smolinari
Copy link

The suggestion with

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

fixed my problem. Thanks @osroot25! 👍

Scott

PropTim added a commit to PropTim/vagrant that referenced this issue Feb 2, 2016
Windows 10 (untested on other versions) has issues with rsync, as the file "/c/some/directory" can't be found. Adding the "/cygwin" + fixes it. See related thread and comments: hashicorp#3230 (comment)
@PropTim
Copy link

PropTim commented Feb 2, 2016

The original problem is still on windows 10. The line edit fixed it:

hostpath = "/cygwin" + Vagrant::Util::Platform.cygwin_path(hostpath)

@smolinari
Copy link

This issue is still in 1.8.1 too.

Scott

@terrancesnyder
Copy link

+1 Still doesnt work on 10

@AgentCormac
Copy link

+1 Vagrant 1.8.1 & Win7

@hollowimage
Copy link

+1 on win10 w/ embedded git bins into powershell.

@strarsis
Copy link

+1 Vagrant 1.8.5 on Windows 10

@hollowimage
Copy link

Updating to lates (1.8.5) fixed the issue for me.

@strarsis if you got 1.8.5 and its not working, maybe the upgrade didnt finish properly? How does the rsync_helper.rb look for you? Maybe the installation got messed up?

meanwhile, try this: #3230 (comment)

@strarsis
Copy link

strarsis commented Aug 31, 2016

I am using cygwin rsync now instead of cwRsync and it works fine.

@craigsagit
Copy link

Thank you @starrychloe

@chebaby
Copy link

chebaby commented Oct 11, 2018

@mdoelker you pointed me in to the right direction

thank you

@ghost
Copy link

ghost commented Mar 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests