guard / listen

The Listen gem listens to file modifications and notifies you about the changes.

Home Page:https://rubygems.org/gems/listen

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Events not firing over vagrant shared folder

drnic opened this issue · comments

Scenario:

  • Running listen (via kicker) inside vagrant
  • It is watching a file within a vagrant shared folder (e.g. /vagrant/README.md)
  • When I touch the file within vagrant, listen triggers (and kicker does its thing)
  • When I touch the file outside of vagrant, listen does not trigger
  • Yet, the filestamp of the watched file has changed as expected

/cc @johnbender @mitchellh (suggests from vagrant perspective?)

This is due to the way that the VirtualBox shared folder system is implemented. It doesn't properly trigger filesystem notification events on the guest if it is touched from the host (and vice versa as well).

I don't think this is a bug with this project or Vagrant. However, listen may be able to watch file system properties (file mtime and such) and see the differences.

Listen has a polling adapter which does not depend on filesystem notifications. Could you try it and see if it helps? (To use it you have to enable the :force_polling option. See the readme for more info)

I just come back from vacation, this is still an issue?

I'm also having this same issue. Polling works fine for me (Lion as the host, Ubuntu 12.04 as vagrant) but I'd rather not eat up my processor time unnecessarily.

To understand this better: is this a problem outside of listen, or is it something which can be fixed in listen? I note elsewhere that Watchr appears to work in this scenario (I've yet to try it myself) and judging by their implementation they keep track of the a/m/ctime: https://github.com/mynyml/watchr/blob/master/lib/watchr/event_handlers/unix.rb

@ideasasylum Watchr use a different (evented) approach than Listen (that have some caveat, like not detecting new files). So if VirtualBox shared folder doesn't trigger filesystem notification events I think polling is the only option here. Sorry.

@thibaudgg ah, thanks for the explanation. If it was something that could be fixed I'd have had a go myself but polling seems like the best approach for the moment