I actually didn’t realise this until last week (because I don’t read enough) but there’s actually more than one way to sync folders to a vagrant guest. I was tripping up because an ubuntu box I was using wasnt syncing files live when I updated those same files on the host. But a separate centos box was syncing files perfectly..
So.. it was because the ubuntu box was using rsync to sync the files and the centos box was using the default vboxsf.
Which got me thinking I should write this down for next time when I get tripped up…
config.vm.synced_folder "/my/host/folder", "/my/guest/folder/", owner: "root", group: "root"
if you use vboxsf and either nginx or apache, you need to turn of sendfile or your webpage won’t refresh css, js, html files when you edit them on your host:
config.vm.synced_folder "/my/host/folder", "/my/guest/folder/", type: "rsync"
This one made me think something was broken, but it’s just because I didn’t read the instructions. You need to open a new tab and start the rsync
$ vagrant rsync-auto
Then your files will update in the guest when you edit them on the host.
If you are dev-ing something nodejs, vboxsf and rsync will unveil a tangible lagginess that is only obvious when working with a bajillion files.
If you need to improve the speed, try nfs. I never really tried to use it, but the docs can explain them better.
config.vm.synced_folder "/my/host/folder", "/my/guest/folder/", type: "nfs"
There’s also SMB, but I’m not interested.