I'm using Vagrant to set up an ubuntu box on Virtualbox. In the vagrant file I've specified synced folders to sync my code with the guest:
config.vm.synced_folder "/host/target/webapp", "/guest/webapp"
The problem I have only appears when I the machine is destroyed and then rebuilt with vagrant up. In this case Vagrant syncs my folders on the guest to my folder on the host, instead of host to guest.
"/guest/webapp" ---> "/host/target/webapp"
I don't like this behaviour at all, if I haven't checked in my code on the host to my version control I will loose my code.
Should the sync be bidirectional? Is there a way to configure it to only sync one way preferable host to guest. Could not find anything about this in vagrant basic sync
In comments below there where suggestions that it where my provisioning (Chef-Solo) that where the cause of the problem. To exclude the provisioning phase from this I did following:
Vagrant up --no-provision
The hosts content where synced to the guest.
rm -r /guest/webapp/ on the guest
Resulted in the hosts content where removed as well.
mkdir /guest/webapp/test on the guest
The created folder test where also created on the host.
I think this proves that the sync is bidirectional.
/vagrantwith the current folder. for this case (the /vagrant folder) you confirm it works correctly ? - Frederic Henrivagrant upfirst time with no provisioningvagrant up --no-provisionand you will see the host folder is not altered, it must come from your provisioning - Frederic Henrivagrant upfirst time with no provisioningvagrant up --no-provisionand you will see the host folder is not altered - Frederic Henri