-
Notifications
You must be signed in to change notification settings - Fork 247
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
Crashes (OSX) on directories with colons in their names #361
Comments
Thanks. I don't even use OSX myself, so I'll have to wait until it's fixed. |
Thank you so much for this bug report! Now I understand why this was not working… |
I started to look into this issue and have some interesting information to share. I dug into the from: https://github.com/thibaudgg/rb-fsevent/blob/master/lib/rb-fsevent/fsevent.rb#L36 class FSEvent
def run
@pipe = open_pipe
@running = true
# please note the use of IO::select() here, as it is used specifically to
# preserve correct signal handling behavior in ruby 1.8.
while @running && IO::select([@pipe], nil, nil, nil)
if line = @pipe.readline
modified_dir_paths = line.split(':').select { |dir| dir != "\n" }
callback.call(modified_dir_paths)
end
end
rescue Interrupt, IOError, Errno::EBADF
ensure
stop
end
end The important line here: Working within the constraints of module Listen
module Adapter
# Adapter implementation for Mac OS X `FSEvents`.
#
class Darwin < Base
module FSEventRefinement
refine ::FSEvent do
def run
@pipe = open_pipe
@running = true
# please note the use of IO::select() here, as it is used specifically to
# preserve correct signal handling behavior in ruby 1.8.
while @running && IO::select([@pipe], nil, nil, nil)
if line = @pipe.readline
# First iterate through passed in list, searching for known ones
known_dirs, unknown_dirs = line.split(':').partition { |s| Dir.exists?(s) }
# Then iterate over the list of unknown directories,
# combining them until they either make a known directory
# or we run out of parts to combine
i = 1
while (unknown_dirs.length > 0 && i <= unknown_dirs.length)
attempt = unknown_dirs[0..i].join(':')
if Dir.exists?(attempt)
# Found one! Add it to the list of known and delete it from
# the list of unknown
known_dirs << attempt
(0..i).each { |index| unknown_dirs.delete_at(index) }
else
i += 1
end
end
modified_dir_paths = known_dirs
callback.call(modified_dir_paths)
end
end
rescue Interrupt, IOError, Errno::EBADF
ensure
stop
end
end
end
using FSEventRefinement
end
end
end So this code would solve the issue of directories being split too aggressively then doing nothing but it has other problems. For instance, what happens when Also, a Since OSX is backed by a UNIX based OS, it uses the This documentation from Apple and this StackOverflow answer both advise against using the Thoughts? TL;DR - I don't think this should actually be fixed since naming folders with |
I don't use OSX all (Linux only), so I can't test or maintain anything OSX-specific. (Any code that can be unit-tested on Linux is fine). This means I can't even compile the rb-fsevent watcher binary. However ... Notice you can supply a format to the fsevent_watch binary. So it probably just needs to added to supported options here You'll find that a different format may use a different separator Any format except the default ("classic") should be much easier to work with. (You can even just refine Again - I can't test this myself. But I hope it creates a more robust solution. |
Travis CI has an OSX test environment, so I imagine it should be possible to have it test this one we come up with a solution. I agree that using an alternate format would be the ideal solution. If we want a workaround before then, I think the best one would be, rather than checking the filesystem at all, we could just preprocess the list, look for any non-absolute paths, and combine them with the previous path. The only false negative would be if a directory ends with a colon (because |
@wisq -
Yes, but that totally sucks for "debugging" when things aren't working. There are also edge cases you can't reasonably diagnose on OSX. E.g. I have no example of output with any format, so either I have create the sample output "in my head" based on the (Example: once upon a time I broke OSX support due to how each watcher needed it's own thread).
That's too much work. Changing the format pretty much guarantees you'll see which files contain a ':' or not. And setting the format is simply not implemented on the Ruby side, so changing the format is trivial. The important part is: edge cases. I'd suggest the following:
(I can help with 2 if I get some fixtures and someone creates at least a failing PR with 1). |
This issue is over 5 years old. Probably time to close it?! |
Sample program:
If you touch files inside
/tmp/foo:bar
,listen
will receive two events: one for/tmp/foo
and one forbar
. The latter causes an error due to being a relative path:This is caused by guard/rb-fsevent#59, and I'm only reporting it here to let you know it's an ongoing issue, and/or in case you want to work around it until that bug is fixed.
The text was updated successfully, but these errors were encountered: