When watching several directories, only the last is actually watched. #243

Closed
chriseppstein opened this Issue Jul 11, 2014 · 7 comments

Comments

Projects
None yet
3 participants
@chriseppstein

Listen version: 2.7.9

require 'listen'

dirs_to_watch = %w(
  anotherdir
  somedir
)

listener = Listen.to(*dirs_to_watch) do |added, modified, removed|
  puts "Listen fired callback"
end

listener.start.join

The callback only fires when filesystem events occur on the last directory specified.

@chriseppstein chriseppstein referenced this issue in Compass/compass Jul 11, 2014

Closed

Alpha 20 #1709

@chriseppstein

This comment has been minimized.

Show comment
Hide comment
@chriseppstein

chriseppstein Jul 11, 2014

Ruby version: 2.0.0-p247

Ruby version: 2.0.0-p247

chriseppstein added a commit to Compass/compass that referenced this issue Jul 11, 2014

nex3 added a commit to sass/sass that referenced this issue Jul 18, 2014

@thibaudgg

This comment has been minimized.

Show comment
Hide comment

@kaelig kaelig referenced this issue in guardian/frontend Aug 6, 2014

Merged

Update npm and ruby dependencies #5393

@e2

This comment has been minimized.

Show comment
Hide comment
@e2

e2 Sep 14, 2014

Contributor

Works in Linux, so it looks like an issue with darwin/FSEvent adapter (I don't have a Mac to properly test or debug on).

What changed - I needed for each watched directory to have a separate callback (to unify and simplify Listen's adapters). (see https://github.com/guard/listen/blob/master/lib/listen/adapter/darwin.rb)

@thibaudgg - could you confirm I'm using rb-fsevent the right way (i.e. calling watch multiple times on the same FSEvent object before calling run)?

Contributor

e2 commented Sep 14, 2014

Works in Linux, so it looks like an issue with darwin/FSEvent adapter (I don't have a Mac to properly test or debug on).

What changed - I needed for each watched directory to have a separate callback (to unify and simplify Listen's adapters). (see https://github.com/guard/listen/blob/master/lib/listen/adapter/darwin.rb)

@thibaudgg - could you confirm I'm using rb-fsevent the right way (i.e. calling watch multiple times on the same FSEvent object before calling run)?

@e2 e2 added bug darwin labels Sep 14, 2014

@thibaudgg

This comment has been minimized.

Show comment
Hide comment
@thibaudgg

thibaudgg Sep 15, 2014

Member

@e2 calling multiple time watch will not work as it overwrites the @paths list each time,I would only call watch once with the list of directories.

Member

thibaudgg commented Sep 15, 2014

@e2 calling multiple time watch will not work as it overwrites the @paths list each time,I would only call watch once with the list of directories.

@e2

This comment has been minimized.

Show comment
Hide comment
@e2

e2 Sep 15, 2014

Contributor

@thibaudgg - I need one callback per directory (to later match the original watched directory based on the callback), so the fix is to have multiple FSEvent objects I guess.

Could you review: #257 ?

Ideally I'd add acceptance specs for this (mocking in adapter specs wouldn't make much sense), but looks like way too much work for now - acceptance specs and fixtures currently assume everything happens in a single watched directory.

Contributor

e2 commented Sep 15, 2014

@thibaudgg - I need one callback per directory (to later match the original watched directory based on the callback), so the fix is to have multiple FSEvent objects I guess.

Could you review: #257 ?

Ideally I'd add acceptance specs for this (mocking in adapter specs wouldn't make much sense), but looks like way too much work for now - acceptance specs and fixtures currently assume everything happens in a single watched directory.

@e2

This comment has been minimized.

Show comment
Hide comment
@e2

e2 Nov 11, 2014

Contributor

This is still broken after my "fix"- but now only the first directory is watched.

Contributor

e2 commented Nov 11, 2014

This is still broken after my "fix"- but now only the first directory is watched.

@e2

This comment has been minimized.

Show comment
Hide comment
@e2

e2 Nov 13, 2014

Contributor

Sorry for the delay, folks, but I had to rework how threads are used and finally add some specs to avoid breaking this every again.

Contributor

e2 commented Nov 13, 2014

Sorry for the delay, folks, but I had to rework how threads are used and finally add some specs to avoid breaking this every again.

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