Vagrant: Cannot configure shared folders on Windows 10

Created on 8 Oct 2017  ยท  11Comments  ยท  Source: hashicorp/vagrant

Please note that the Vagrant issue tracker is reserved for bug reports and
enhancements. For general usage questions, please use the Vagrant mailing list:
https://groups.google.com/forum/#!forum/vagrant-up. Thank you!

Vagrant version

Vagrant 2.0.0

Host operating system

Windows 10 Home

Guest operating system

ubuntu/trusty64

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.synced_folder '.', '/vagrant', disabled: true
  config.vm.synced_folder "data/", "/vagrant/vagrant_data"
end

Debug output

https://gist.github.com/alankritjoshi/e0adaa682da9575e2d5c2e1bd9c3aeb6

Expected behavior

Shared folder and files

Actual behavior

No sharing possible. VirtualBox has the incorrect path.

Host: \?\D:Computer ScienceComputer Systems\data
Guest; vagrant_vagrant_data

Steps to reproduce

Install virtualbox 5.1.28 and vagrant 2.0.0

  1. vagrant up
  2. vagrant ssh

References

hoswindows synced-foldervbox waiting-reply

Most helpful comment

@alankritjoshi Hi there. When the guest is brought up, are there no contents in the /vagrant/vagrant_data folder?

$ vagrant ssh -- ls -l /vagrant/vagrant_data

All 11 comments

Hi @alankritjoshi - I don't actually see an error in the gist you provided...it looks like maybe you had run vagrant up on an already provisioned machine? Did you see the error the first time around?

I don't see any error. I am unable to share any folders. I shared the log hoping it would help in figuring out what I am doing wrong.

After I start up a new vagrant box, in the Virtualbox the folders are set as:

Windows 10:
\?\D:Computer ScienceComputer Systems\data
ubuntu/trusty64:
vagrant_vagrant_data

The folder that I want to be shared is:
Windows 10:
D:Computer ScienceComputer Systems\data
ubuntu/trusty64:
/vagrant/vagrant_data

I am assuming the paths being set in VirtualBox are inaccurate. So I am unable to figure out why I cannot share the folders.

OH oops, I understand now :) Interesting that it does not result in an error. Anyway I'll get this properly labeled up.

@alankritjoshi Hi there. When the guest is brought up, are there no contents in the /vagrant/vagrant_data folder?

$ vagrant ssh -- ls -l /vagrant/vagrant_data

The guest works fine as it is when I ssh into it. So yes, there is data in it as wrote code etc. in it. The problem is the data in vagrant_data is not shown in my Windows. On Windows, in my project directory (where I have Vagrantfile), there is a data folder which doesn't have anything that I have in my guest's vagrant_data.

@alankritjoshi For a mount to be successful, the target directory must be empty. In this case, the file system on your host computer is being mounted to /vagrant/vagrant_data on the guest machine. That means that the /vagrant/vagrant_data directory on the guest machine is the target. You must ensure the /vagrant/vagrant_data directory is empty on the guest machine. Then you can run vagrant reload which will restart the guest and mount the directory.

Once the directory is mounted, you can add files in the guest or on the host and you will see them in both places.

Cheers!

I think I misunderstood what you asked. I am assuming when you said

When the guest is brought up,

you meant when the guest is upped for the first time. I confirm that it is empty when I set up a new vagrant project. Even the Windows 10 directory which is mapped to it is empty. So sharing is not working.

@alankritjoshi Hi, is this still an issue you are encountering with the latest version of Vagrant? If so, I will investigate further. Thanks!

Vagrant version: 2.1.2
VirtualBox version: 5.2.14
(latest versions at this moment)

Got if fixed by doing those two things:

  1. Editing line 271 of C:\HashiCorp\Vagrant\embedded\gems\2.1.2\gems\vagrant-2.1.2\lib\vagrant\util\platform.rb
    Original: "\\\\?\\" + path.gsub("/", "\\")
    Fixed: path.gsub("/", "\\")
    Note: line number may change on others versions, just search for "\\?\" (without quotes)
  1. Installing those two plugins:
vagrant plugin install vagrant-winnfsd
vagrant plugin install vagrant-vbguest

If it fixed the problem but now you get an error like GuestAdditions versions on your host (5.2.14) and guest (5.1.34) do not match.
see https://github.com/dotless-de/vagrant-vbguest/issues/300#issuecomment-402881079

Also, if you encounter problems with symbolics links on windows, add this to your Vagrant file

config.vm.provider "virtualbox" do |v|
    v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end

I do not have a vagrant installation to verify this on my end. Thanks for the fixes.

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.

Was this page helpful?
0 / 5 - 0 ratings