Triggering file changes over VirtualBox shared folders #269

Closed
axsuul opened this Issue Mar 27, 2012 · 29 comments

Projects

None yet

7 participants

@axsuul
axsuul commented Mar 27, 2012

I'm using vagrant on Windows with guard running on an Ubuntu VM. I can't seem to trigger file changes over the VirtualBox shared folder. If I touch the files within Ubuntu, it picks up the file changes (with rb-inotify). Touching the files on Windows doesn't trigger anything, even with polling. Any suggestions?

@axsuul
axsuul commented Mar 27, 2012

It looks like this is a VirtualBox issue. mitchellh/vagrant#707

@axsuul axsuul closed this Mar 27, 2012
@netzpirat
Contributor

Thanks for the info. You can force the use of the polling adapter, see my comment in issue #266

@axsuul axsuul reopened this Apr 3, 2012
@axsuul
axsuul commented Apr 3, 2012

Hmm well I updated to the latest VirtualBox which is supposed to include the fix. I've also tried the polling method you mentioned with

bundle exec guard --no-vendor

When touching the files on Windows, I can see that the last modified date reflects correctly but guard still isn't being triggered. Any suggestions?

@netzpirat
Contributor

Does Guard show the message Using polling (Please help us to support your system better than that). on start?

@axsuul
axsuul commented Apr 3, 2012

Yep, here is the full output

$ bundle exec guard --no-vendor
Using polling (Please help us to support your system better than that).
Guard could not detect any of the supported notification libraries.
Guard is now watching at '/vagrant'
Starting Spork for RSpec
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork server for RSpec successfully started
Guard::RSpec is running, with RSpec 2!
@thibaudgg
Member

Please can you try if it works with the Listen gem. Thanks!

@netzpirat
Contributor

Guard 1.1.0 has been released with Listen integration, please give it a try and re-open the issue when you still have an issue with it.

@netzpirat netzpirat closed this Jun 3, 2012
@axsuul
axsuul commented Jun 3, 2012

I've updated to Guard 1.1.0 and still having the same issue. My test involved

$ bundle exec guard

and then initiating file saves on a few *_spec.rb files from Windows. From within the virtual machine itself (Ubuntu), I can verify it works with a

$ touch *_spec.rb

However, I have a strong feeling this is a VirtualBox issue.

@netzpirat netzpirat reopened this Jun 4, 2012
@netzpirat
Contributor

Since Guard 1.1.0 there's now a latency CLI option that has influence on polling adapter. Can you play with this option to see if you can make it work?

@axsuul
axsuul commented Jun 5, 2012

@netzpirat What would you recommend? Been doing something like this but with no success =(

bundle exec guard -l 1000
@netzpirat
Contributor

I didn't give a recommendation on purpose, because I didn't implement anything in the much improved Listen gem and have thus almost no knowledge in this area. Perhaps @thibaudgg or @Maher4Ever can join to help?

From my understanding the polling listener compares the file mtime and also compares the content checksum on subsequent modifications. The latency is the time in between the polling adapter actions, in which it tries to find the modified files. According to this Virtualbox Ticket, the copied file now has the timestamp of the host os when it was copied into the shared folder and not the time when it was copied into the vm (do I understand this correctly?) So if the latency of the os->vm copy process is bigger the Guard's latency, the the file change will not be catched? In any case I would now try to decrease the Guard latency.

Can you please analyse your inotify events, as described in the wiki and add your finding to it wiki. Perhaps this helps to understand the inotify issue.

@thibaudgg
Member

@netzpirat thanks for the Virtualbox ticket research!
This issue seems to have been fixed in Virtualbox release 4.1.12, @Axsuul do you have that version?

@Vizakenjack

I updated to latest virtualbox, then installed guest additions, and then run guard with -p option. It works well now, but test runs twice if I modify file in Windows. When I try to "touch test.rb" in linux, it runs only 1 time.

@thibaudgg thibaudgg closed this Jun 9, 2012
@rchampourlier

Using VirtualBox 4.1.18 with updated Guest Additions, the host being a MacOS X 10.7.4 and the guest an Ubuntu 10.04.3, I have to run guard with guard -p -l 10 to make it work without keeping my CPU at 100% charge.

I understand the non-polling approach is not supported, but I'm getting this annoying double-trigger @Vizakenjack is getting. Did someone find a neat solution?

@thibaudgg
Member

@rchampourlier have you the last version of Guard & Listen?

@rchampourlier

@thibaudgg Sorry I did specify my OSes versions and I forgot Guard & Listen...

Guard is 1.2.3
Listen is 0.4.7

I think these are the latest versions?

@thibaudgg
Member

@rchampourlier yep it is, it difficult to know from where the double-trigger is coming, have you try with another editor?

@axsuul
axsuul commented Jul 31, 2012

Updated Guest Additions to 4.1.18 and now working with polling (although ti can be a bit slow). I don't seem to be getting the double trigger problem. Thanks for the help guys!

@rchampourlier

Guard is launched with: bundle exec guard -p -l 10

  • touch Guardfile on guest: 1 trigger
  • touch Guardfile on host: 1 trigger
  • Editing and saving the file with SublimeText 2.0.1:
    • without changing the file content: 1 trigger
    • after changing the file content: 2 triggers
  • Editing and saving the file with TextMate 1.5.11: same behavior as SublimeText.
@thibaudgg
Member

@rchampourlier interesting and on a local file editing and saving with SublimeText/TextMate only triggers one time with polling?

@rchampourlier

@thibaudgg I just tested on a local file with SublimeText and TextMate. We have the exact same behavior as through Vagrant. When the file is changed, we have a double trigger if guard is run with -p (I tested with -p -l 10 and -p the result is the same). When the file is just saved, we have a single trigger.

@thibaudgg
Member

Ok, it could be an error in the polling adapter of Listen. Could you please paste the debug output of Guard when running with bundle exec guard -d -p -l 10 please?

Also note that we are working to improve monitoring of remote filesystems events: guard/listen#57

@tom-w
tom-w commented Aug 10, 2012

I'm also hitting the double trigger issue each time I save an edit in Sublime on Win7 x64. I ran bundle exec guard -d -p -l 10 as asked, and I copied the result I see below. Note that at 19:23:13 the interactor and starts and stops instantly:

$ bx guard -d -p -l 10
Guard uses GNTP to send notifications.
DEBUG (19:21:45): Command execution: chcp
Guard is now watching at 'c:/workspace/cognate'
DEBUG (19:21:45): Command execution: hash stty
DEBUG (19:21:45): Hook :start_begin executed for Guard::RSpec
Guard::RSpec is running, with RSpec 2!
Running all specs
DEBUG (19:21:45): Command execution: bundle exec rspec --help
DEBUG (19:21:49): Command execution: bundle exec rspec --fail-fast -f progress -r c:/R
ailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-rspec-1.2.1/lib/guard/rspec/for
matters/notification_rspec.rb -f Guard::RSpec::Formatter::NotificationRSpec --out /dev
/null --failure-exit-code 2 spec
....

Finished in 7.53 seconds
4 examples, 0 failures

Randomized with seed 56900

DEBUG (19:22:21): Hook :start_end executed for Guard::RSpec
DEBUG (19:22:21): Command execution: hash stty
DEBUG (19:22:21): Start interactor
DEBUG (19:22:41): Stop interactor
DEBUG (19:22:41): Command execution: hash stty
DEBUG (19:22:41): Trying to run Guard::RSpec#run_on_modifications with ["spec/models/n
ode_spec.rb"]
DEBUG (19:22:41): Hook :run_on_changes_begin executed for Guard::RSpec
Running: spec/models/node_spec.rb
DEBUG (19:22:41): Command execution: bundle exec rspec --fail-fast -f progress -r c:/R
ailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-rspec-1.2.1/lib/guard/rspec/for
matters/notification_rspec.rb -f Guard::RSpec::Formatter::NotificationRSpec --out /dev
/null --failure-exit-code 2 spec/models/node_spec.rb
...

Finished in 6.75 seconds
3 examples, 0 failures

Randomized with seed 4440

DEBUG (19:23:13): Hook :run_on_changes_end executed for Guard::RSpec
DEBUG (19:23:13): Command execution: hash stty
DEBUG (19:23:13): Start interactor
DEBUG (19:23:13): Stop interactor
DEBUG (19:23:13): Command execution: hash stty
DEBUG (19:23:13): Trying to run Guard::RSpec#run_on_modifications with ["spec/models/n
ode_spec.rb"]
DEBUG (19:23:13): Hook :run_on_changes_begin executed for Guard::RSpec
Running: spec/models/node_spec.rb
DEBUG (19:23:13): Command execution: bundle exec rspec --fail-fast -f progress -r c:/R
ailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-rspec-1.2.1/lib/guard/rspec/for
matters/notification_rspec.rb -f Guard::RSpec::Formatter::NotificationRSpec --out /dev
/null --failure-exit-code 2 spec/models/node_spec.rb
...

Finished in 6.74 seconds
3 examples, 0 failures

Randomized with seed 10269

DEBUG (19:23:44): Hook :run_on_changes_end executed for Guard::RSpec
DEBUG (19:23:44): Command execution: hash stty
DEBUG (19:23:44): Start interactor
>

PS Separately, I'm defaulting to the polling adapter because the listen gem doesn't seem to notice file changes in my working directory. I've installed and removed combinations of rb-fsevent, rb-notifu, rb-fchange, and wdm, but guard doesn't pick up changes. But polling seems to work perfectly, except for this double trigger issue.

@thibaudgg
Member

@Maher4Ever do you have any thoughts on that one?

@Maher4Ever
Member

Unfortunately, I wasn't able to reproduce the double trigger issue. Does anyone have a repeatable way to reproduce this issue? (preferably starting with a clean install of an operating system and ruby).

@rchampourlier

I'm looking into a reproductible way. What would be the lowest-requirement-approach to test Guard triggering (without the need for a Rails/Sinatra project and the appropriate guards?). Is there a 'guard-test' for example?

[EDIT] Just created a new guard: guard-self_test.

@rchampourlier

Done!

I've reproduced it on a fresh Vagrant box with Lucid32 and rbenv install of Ruby 1.9.3-p194. The test project is available on this repo. I've set the box to lucid32-ruby-1.9.3-p194 in the Vagrantfile which is a box I build using this but you can use lucid32 instead and install Ruby 1.9.3-p194 yourself.

The test log is in this gist. We can see that editing a file in SublimeText causes two triggers, when all other cases trigger only once.

The test procedure is:

  • touch touch-from-host from the host
  • touch touch-in-guest inside the guest machine
  • save touch-in-sublime-textwithout changing the file in SublimeText
  • edit and save edit-in-sublime-text after changing the file in SublimeText
@Vizakenjack

I have the same issue with sublime. Hope you fix it soon.

@thibaudgg
Member

We have an issue opened on Listen about this issue, feel free to participate. Pull requests are welcome.
guard/listen#57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment