rgl / windows-vagrant

Windows 11/2022/2025 Base Vagrant Box (https://app.vagrantup.com/rgl)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error when trying to use config.vm.synced_folder with rsync

lwiechec opened this issue · comments

Hi, thanks for making this project, it's very cool to be able to build own Windows base box!

I have done so for Win 2016 for libvirt but when I try to in the following Vagrantfile

Vagrant.configure("2") do |config|

  config.vagrant.plugins = [ "vagrant-libvirt" ]

  # we are using our freshly made Win 2016 base box
  config.vm.define :test_vm do |test_vm|
    test_vm.vm.box = "windows-2016-amd64"
    test_vm.vm.hostname = "littlewin"
  end

  config.vm.network "private_network", type: "dhcp"
  config.vm.synced_folder "./", "c:/vagrant", type: "rsync"

  # details to the libvirt provider
  config.vm.provider :libvirt do |libvirt|
    libvirt.host = "littlewin"
    libvirt.driver = "kvm"
    libvirt.memory = 2048
    libvirt.cpus = 2
  end

  #
  # Run Ansible from the Vagrant Host
  #
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "playbook.yml"
  end

end

the VM's startup fails with this error:

θ75° [luke:~/work/projects/vagrant-win2016] master(+15/-1)* 1 ± vagrant up
Bringing machine 'test_vm' up with 'libvirt' provider...
==> test_vm: Creating image (snapshot of base box volume).
==> test_vm: Creating domain with the following settings...
==> test_vm:  -- Name:              vagrant-win2016_test_vm
==> test_vm:  -- Domain type:       kvm
==> test_vm:  -- Cpus:              2
==> test_vm:  -- Feature:           acpi
==> test_vm:  -- Feature:           apic
==> test_vm:  -- Feature:           pae
==> test_vm:  -- Memory:            2048M
==> test_vm:  -- Management MAC:    
==> test_vm:  -- Loader:            
==> test_vm:  -- Nvram:             
==> test_vm:  -- Base box:          windows-2016-amd64
==> test_vm:  -- Storage pool:      default
==> test_vm:  -- Image:             /var/lib/libvirt/images/vagrant-win2016_test_vm.img (60G)
==> test_vm:  -- Volume Cache:      default
==> test_vm:  -- Kernel:            
==> test_vm:  -- Initrd:            
==> test_vm:  -- Graphics Type:     spice
==> test_vm:  -- Graphics Port:     -1
==> test_vm:  -- Graphics IP:       127.0.0.1
==> test_vm:  -- Graphics Password: Not defined
==> test_vm:  -- Video Type:        qxl
==> test_vm:  -- Video VRAM:        9216
==> test_vm:  -- Sound Type:	
==> test_vm:  -- Keymap:            en-us
==> test_vm:  -- TPM Path:          
==> test_vm:  -- INPUT:             type=tablet, bus=usb
==> test_vm:  -- CHANNEL:             type=unix, mode=
==> test_vm:  -- CHANNEL:             target_type=virtio, target_name=org.qemu.guest_agent.0
==> test_vm:  -- CHANNEL:             type=spicevmc, mode=
==> test_vm:  -- CHANNEL:             target_type=virtio, target_name=com.redhat.spice.0
==> test_vm: Creating shared folders metadata...
==> test_vm: Starting domain.
==> test_vm: Waiting for domain to get an IP address...
==> test_vm: Waiting for SSH to become available...



==> test_vm: Setting hostname...
==> test_vm: Waiting for machine to reboot...
==> test_vm: Forwarding ports...
==> test_vm: 5985 (guest) => 55985 (host) (adapter eth0)
==> test_vm: 5986 (guest) => 55986 (host) (adapter eth0)
==> test_vm: Configuring and enabling network interfaces...
==> test_vm: Rsyncing folder: /home/luke/work/projects/vagrant-win2016/ => /cygdrive/c/vagrant
==> test_vm: Exporting NFS shared folders...
==> test_vm: Preparing to edit /etc/exports. Administrator privileges will be required...
==> test_vm: Clearing any previously set forwarded ports...
==> test_vm: Removing domain...
Traceback (most recent call last):
	58: from /home/luke/.vagrant.d/gems/2.7.2/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
	57: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'
	56: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `action'
	55: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `call'
	54: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/environment.rb:613:in `lock'
	53: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/machine.rb:212:in `block in action'
	52: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/machine.rb:240:in `action_raw'
	51: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
	50: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
	49: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
	48: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:116:in `call'
	47: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	46: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
	45: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	44: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/box_check_outdated.rb:36:in `call'
	43: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	42: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/call.rb:53:in `call'
	41: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
	40: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
	39: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
	38: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:116:in `call'
	37: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	36: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:107:in `block in finalize_action'
	35: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	34: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/set_name_of_domain.rb:32:in `call'
	33: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	32: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/handle_storage_pool.rb:57:in `call'
	31: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	30: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
	29: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	28: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/handle_box_image.rb:127:in `call'
	27: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	26: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/create_domain_volume.rb:87:in `call'
	25: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	24: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/create_domain.rb:374:in `call'
	23: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	22: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/provision.rb:80:in `call'
	21: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	20: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.3.0/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb:12:in `call'
	19: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	18: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/action_cleanup.rb:25:in `call'
	17: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	16: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/synced_folder_cleanup.rb:28:in `call'
	15: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	14: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/delayed.rb:19:in `call'
	13: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	12: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/synced_folders.rb:90:in `call'
	11: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/synced_folders.rb:90:in `each'
	10: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/action/builtin/synced_folders.rb:93:in `block in call'
	 9: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/synced_folder.rb:79:in `enable'
	 8: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/synced_folder.rb:79:in `synchronize'
	 7: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/synced_folder.rb:81:in `block in enable'
	 6: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/environment.rb:613:in `lock'
	 5: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/synced_folders/nfs/synced_folder.rb:83:in `block (2 levels) in enable'
	 4: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/capability_host.rb:111:in `capability'
	 3: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/lib/vagrant/capability_host.rb:111:in `call'
	 2: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/hosts/linux/cap/nfs.rb:82:in `nfs_export'
	 1: from /usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/hosts/linux/cap/nfs.rb:186:in `nfs_write_exports'
/usr/share/rubygems-integration/all/gems/vagrant-2.2.9/plugins/hosts/linux/cap/nfs.rb:186:in `stat': No such file or directory @ rb_file_s_stat - /etc/exports (Errno::ENOENT)

It seems that Vagrant is still trying to employ NFS somehow, even though I tell it to use rsync:

...
  config.vm.synced_folder "./", "c:/vagrant", type: "rsync",#, :nfs => !RUBY_PLATFORM.downcase.include?("w32")
...

and I do see it using RSync in the log:

==> test_vm: Rsyncing folder: /home/luke/work/projects/vagrant-win2016/ => /cygdrive/c/vagrant

so - I am puzzled! :)

...my puzzlement is somewhat reduced when I just - turn off the NFS:

  config.nfs.functional = false # disables NSF
  config.vm.synced_folder "./", "c:/vagrant", type: "rsync"

sorry for a non-bug!

That's interesting, it works in my machine as:

# replace the default synced_folder with something that works in the base box.
# NB for some reason, this does not work when placed in the base box Vagrantfile.
config.vm.synced_folder '.', '/vagrant', type: 'rsync', rsync__exclude: [
'.vagrant/',
'.git/',
'*.box']

There are a couple of differences. I'm using . and /vagrant, but you are using ./and c:/vagrant. Can you try that instead?

thanks Rui - using /vagrant means I don't have to explicitly turn off NFS.