Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WDM watcher breaks --watchdir parameter #63

Closed
agross opened this issue Sep 24, 2012 · 8 comments
Closed

WDM watcher breaks --watchdir parameter #63

agross opened this issue Sep 24, 2012 · 8 comments

Comments

@agross
Copy link

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
Copy link
Member

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

@windy
Copy link

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
Copy link
Member

@Maher4Ever can you look at it please?

@Maher4Ever
Copy link
Contributor

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
Copy link
Contributor

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

@agross
Copy link
Author

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
Copy link
Contributor

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

@Maher4Ever
Copy link
Contributor

@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.

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

No branches or pull requests

5 participants