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

Cannot handle directories with colons in their name #59

Closed
wisq opened this issue Jan 2, 2016 · 5 comments
Closed

Cannot handle directories with colons in their name #59

wisq opened this issue Jan 2, 2016 · 5 comments

Comments

@wisq
Copy link

wisq commented Jan 2, 2016

Due to using colon as a delimiter, rb-fsevent cannot correctly report events on files that have actual colons in their names. This came up with my jekyll blog, whereby I had a topic tag with a colon in it.

The effects are broader: since the colon causes it to suddenly receive a non-absolute path (e.g. /tmp/foo:bar gets turned into /tmp/foo and bar), this also breaks gems like listen that expect to always receive an absolute path, and crash (due to Pathname relative_path_from attempts) when they get a relative path.

The simplest solution would probably be to either use NULs (\0) as the delimiter character, or if that's not possible, to implement very basic backslash escaping (:\:, \\\).

@wisq
Copy link
Author

wisq commented Jan 2, 2016

Correction: this only applies to directories with colons in their name, since the watcher only reports the directory name. Issue title fixed.

Example traceback (using the listen gem):

E, [2016-01-02T04:59:29.802188 #96661] ERROR -- : run() in thread failed: different prefix: "" and "/private/tmp/foo:bar":/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/2.2.0/pathname.rb:508:in `relative_path_from'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/listen-2.8.4/lib/listen/adapter/darwin.rb:48:in `block in _process_event'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/listen-2.8.4/lib/listen/adapter/darwin.rb:43:in `each'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/listen-2.8.4/lib/listen/adapter/darwin.rb:43:in `_process_event'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/listen-2.8.4/lib/listen/adapter/base.rb:47:in `block (2 levels) in configure'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rb-fsevent-0.9.7/lib/rb-fsevent/fsevent.rb:45:in `call'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rb-fsevent-0.9.7/lib/rb-fsevent/fsevent.rb:45:in `run'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/listen-2.8.4/lib/listen/adapter/darwin.rb:39:in `_run'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/listen-2.8.4/lib/listen/adapter/base.rb:58:in `block in start'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/listen-2.8.4/lib/listen/internals/thread_pool.rb:7:in `call'
/Users/wisq/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/listen-2.8.4/lib/listen/internals/thread_pool.rb:7:in `block in add'

This is using the sample program:

require 'listen'
listener = Listen.to('/tmp/foo:bar') do |modified, added, removed|
  puts "modified absolute path: #{modified}"
  puts "added absolute path: #{added}"
  puts "removed absolute path: #{removed}"
end
listener.start # not blocking
sleep

and touching files inside /tmp/foo:bar. The error occurs because listen receives two separate events, one for /tmp/foo and one for bar.

@wisq wisq changed the title Cannot handle files with colons in their name Cannot handle directories with colons in their name Jan 2, 2016
@git-no
Copy link

git-no commented Apr 16, 2016

Have the same error, with Jekyll. Error happens after I save a file in mode jekyll b --watchor jekyll s and Jekyll wants to recreate _site content.

@ttilley
Copy link
Member

ttilley commented May 24, 2017

yeah... this is super shitty. i'm closing all open bugs because rb-fsevent will shortly be deprecated in favor of a version that makes use of FFI (span of a few months). Without communication with a subprocess, this bug will no longer exist in the new library.

...however, rb-fsevent isn't going away entirely and this is absolutely a bug worth fixing despite the library being deprecated. I sincerely apologize. Please be patient and bare with me just a little bit longer.

@ttilley
Copy link
Member

ttilley commented Jun 1, 2017

this should be fixed in rb-fsevent master branch. i'm going to let this sit for a bit before closing.

@ttilley
Copy link
Member

ttilley commented Jun 29, 2017

fixed in 0.10.0 and 0.10.1

@ttilley ttilley closed this as completed Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants