It looks like it's a bug with macOS (possibly El Capitan but confirmed on Sierra) and/or NFS.
See these Vagrant issues:
Most people found that it seems to be related to a filesystem caching issue.
Solution High Sierra (2017-11-21)
Upgrade to High Sierra 10.13.2 Beta 2 as confirmed by JF Bibeau.
Upgraded to High Sierra 10.13.2 Beta 2, removed my cronjob that would periodically do an ls -laR
as a workaround, [...]
I'm happy to report I haven't seen this in almost 2 weeks of using High Sierra. It's completely fixed!
Note that a new, but different, problem seem to have arised on High Sierra related to incorrect listing of files on the guest machine.
Possible workarounds
If upgrading to High Sierra is not possible, here's a couple workarounds.
Update Vagrant and Virtualbox
If possible, update both, though some people mentioned downgrading helped.
Recursive listing on the host (Easy workaround)
Running the following on the host refreshes the filesystem cache:
ls -alR [synced_directory] > /dev/null
or opening the Get info menu of the synced directory seem to work temporarily.
Some people made a cron job to do that every 5 minutes so they never encounter the problem even if it's not a definitive solution.
Someone pointed out that running a recusive listing of only the directory had the same effect and was faster.
find [synced_directory] -type d > /dev/null
Disabling NFS lookupcache
A comment in the issue mentioned:
Disabling NFS lookupcache seems to work, but the performance is
unbearable.
Change permissions of synced directory
On the host machine, give read and write access to Everyone. It also seems to work temporarily, probably for the same caching reason the opening the Get info menu works.
Not using NFS
config.vm.synced_folder "./host", "/vagrant-dir", :mount_options => ["dmode=777", "fmode=777"]
But this has a huge performance downside.
This is a vagrant plugin which allows mounting directories with SSHFS. Though from the drawbacks listed on the repo itself:
Performance is worse than an implementation like NFS
Downgrade to El Capitan
Some people mentioned that they were not having this specific "unlink" problem on El Capitan. So downgrading would be a last resort solution to avoid dealing with it.
Some registered Apple developers have reported the problem on bugreport.apple.com (#28927426 and #33043401) but the information is private.
Apple responded and closed the original bug report, saying:
The issue reported in this bug report is fixed but the High Sierra issue is specific to APFS and not the same issue. Please file a new nug (sic) for that issue. Thank you. We are now closing this bug report.