WDM watcher breaks --watchdir parameter #63

agross opened this Issue Sep 24, 2012 · 8 comments


None yet
5 participants

agross commented Sep 24, 2012

Thank you for introducing me to the --watchdir parameter in a recent discussion.

I tried guard with that parameter, but it seems to be broken on Windows. Through a lot of puts debugging I found that line 80 of the Windows adapter appears to delete the directories to watch such that subsequent calls use a "somewhat empty @directories field. I.e.:

Given @directories is ["C:/Somewhere"] before adapters/windows.rb:80 was run
When adapters/windows.rb:80 was run
Then @directories is [""]

I know this sounds very strange (it indeed is), but given that WDM is a native gem, it might be that it frees some memory that it's not supposed to.

To fix the issue for me, I simply changed said line 80 to:

@directories.map { |d| d.clone }.each { |d| worker.watch_recursively(d, &callback) }

Here's my env:

ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

Original error without the fix:

$ C:\Blah\bundle exec guard --watchdir C:/Somewhere
Guard is now watching at 'C:/Somewhere'
> C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/adapters/windows.rb:81:in `watch_recursively': Can't get the absolute path for the passed directory: ''! (WDM::Error)
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/adapters/windows.rb:81:in `block (2 levels) in init_worker'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/adapters/windows.rb:81:in `each'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/adapters/windows.rb:81:in `block in init_worker'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/adapters/windows.rb:79:in `tap'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/adapters/windows.rb:79:in `init_worker'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/adapters/windows.rb:18:in `initialize'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/adapter.rb:49:in `new'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/adapter.rb:49:in `select_and_initialize'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/listener.rb:200:in `initialize_adapter'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/listen-0.5.2/lib/listen/listener.rb:47:in `start'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/guard-1.3.3/lib/guard.rb:162:in `start'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/guard-1.3.3/lib/guard/cli.rb:104:in `start'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
        from C:/RUBY/lib/ruby/gems/1.9.1/gems/guard-1.3.3/bin/guard:6:in `<top (required)>'
        from C:/Ruby/bin/guard:23:in `load'
        from C:/Ruby/bin/guard:23:in `<main>'

thibaudgg commented Sep 25, 2012

Interesting... I let our Windows expert (@Maher4Ever) answer to that :)

windy commented Jan 28, 2013

@thibaudgg the same problem here, after 4 months, I want to know whether there is an answer to solve this issue, thx :)


thibaudgg commented Jan 28, 2013

@Maher4Ever can you look at it please?


Maher4Ever commented Feb 12, 2013

I tried to reproduces this issue today but I couldn't. I even tried with WDM v0.0.3, but everything worked fine. Do you know of any particular situation or configuration which triggers this issue?


netzpirat commented Feb 12, 2013

@Maher4Ever Great to have you back, a heartily welcome from my side! I hope all is fine with you and your studies.

agross commented Feb 12, 2013

@Maher4Ever I can't either reproduce the issue, but I remember fighting with it for half a day. I don't remember what might have been special about my setup. By now I'm running a newer Ruby with a newer SDK, so probably a version issue there. (I tried reproducing with guard-1.3.3 and listen-0.5.2). Probably @windy has some ideas.

Edit: Tried with 1.9.3-p194 in a VM. Cannot reproduce either.


netzpirat commented Feb 12, 2013

This may be related to to the this Ruby issue that only affects ruby 1.9.3p327 on Windows.


Maher4Ever commented Feb 22, 2013

@netzpirat Thanks man, I'm happy to be back :) Everything is going great right now, and I hope it's the same for you.
@agross Since we can't reproduce this issue, I'll close it for now. Feel free to re-open it when that's needed.

@Maher4Ever Maher4Ever closed this Feb 22, 2013

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