replace rucola with rb-fsevent to fix operation on Ruby 1.9
stepheneb opened this issue · 10 comments
The rb-fsevent gem seems like it could be used instead of rucola to get kicker working on Ruby 1.9.
https://github.com/thibaudgg/rb-fsevent
FSEvents API with signals handled (without RubyCocoa)
Would also need to replace vendor/growlnotifier ... perhaps with ruby-growl: https://github.com/drbrain/ruby-growl
Yes this looks more like it, but I know there are gems out there that also support inotify on GNU/Linux and others. So if we switch I'd rather switch to one that will also work on other platforms. Sadly I can’t come up with the names of the gems atm, but when I find them I'll update this here.
The ruby-growl gem does not seem to support callbacks, though, so I don't think this is the right option. If there are no others, I think we'll just have to write a custom C ext that interfaces with Growl directly. Possibly by using https://github.com/psychs/tinygrowl as a start.
I'd love to have these changes but haven't found the time yet, so are you willing to work on this?
fssm uses inotify on Linux, fsevent on MacOS X and polling elsewhere: https://github.com/ttilley/fssm -- but the fsevent implementation uses the same rucola library kicker uses.
If fssm works with ruby 1.9 on linux and windows then it might make sense to integrate rb-fsevent with it and use this for a cross-platform version of kicker.
I am willing to work on this but time is a problem. I started on the growl stuff but got stuck at the callback problem you noticed.
Here's another one that seems a bit better and has started work on using FFI to access the FSEvents API, although that's not finished yet and currently creates a 1.8+RubyCocoa process when on 1.9: https://github.com/mockko/em-dir-watcher
After manually installing shoulda the em-dir-watcher tests run but don't pass running in Ruby 1.9 on my machine:
[em-dir-watcher-git (master)]$ rake test
(in /Users/stephen/dev/ruby/src/gems/em/em-dir-watcher-git)
All dependencies seem to be installed.
/Users/stephen/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -I"lib:lib:test" "/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/test_monitor.rb" "test/test_tree.rb"
Loaded suite /Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.FFFFEE.....................................
Finished in 96.041409 seconds.
1) Failure:
test: Monitor should combine changes when using a non-zero grace period. (TestMonitor) [test/test_monitor.rb:97]:
<" >> bar/biz, bar/foo"> expected but was
<" >> ">.
2) Failure:
test: Monitor should not report duplicate changes when using a non-zero grace period. (TestMonitor) [test/test_monitor.rb:124]:
<" >> bar/biz, bar/foo"> expected but was
<" >> ">.
3) Failure:
test: Monitor should report each change individually when using a zero grace period. (TestMonitor) [test/test_monitor.rb:74]:
<"bar/foo >> bar/biz"> expected but was
<" >> ">.
4) Failure:
test: Monitor should should report a deletion. (TestMonitor) [test/test_monitor.rb:43]:
<"bar/biz, bar/boo/bizzz, bar/foo"> expected but was
<"">.
5) Error:
test: Monitor should should report entire subtree as changed when a directory is moved away. (TestMonitor):
ArgumentError: same file: /tmp/emdwtest/bar and /tmp/emdwtestalt/bar
test/test_monitor.rb:136:in `block (3 levels) in <class:TestMonitor>'
/Users/stephen/dev/ruby/src/gems/em/em-dir-watcher-git/lib/em-dir-watcher/invokers/subprocess_invoker.rb:42:in `call'
/Users/stephen/dev/ruby/src/gems/em/em-dir-watcher-git/lib/em-dir-watcher/invokers/subprocess_invoker.rb:42:in `block (2 levels) in ready_to_use!'
/Users/stephen/dev/ruby/src/gems/em/em-dir-watcher-git/lib/em-dir-watcher/invokers/subprocess_invoker.rb:42:in `each'
/Users/stephen/dev/ruby/src/gems/em/em-dir-watcher-git/lib/em-dir-watcher/invokers/subprocess_invoker.rb:42:in `block in ready_to_use!'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `call'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `run_machine'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `run'
test/test_monitor.rb:131:in `block in <class:TestMonitor>'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/shoulda-2.11.3/lib/shoulda/context.rb:382:in `call'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/shoulda-2.11.3/lib/shoulda/context.rb:382:in `block in create_test_from_should_hash'
6) Error:
test: Monitor should should report entire subtree as changed when a directory is moved in. (TestMonitor):
ArgumentError: same file: /tmp/emdwtest/bar and /tmp/emdwtestalt/bar
test/test_monitor.rb:153:in `block (3 levels) in <class:TestMonitor>'
/Users/stephen/dev/ruby/src/gems/em/em-dir-watcher-git/lib/em-dir-watcher/invokers/subprocess_invoker.rb:42:in `call'
/Users/stephen/dev/ruby/src/gems/em/em-dir-watcher-git/lib/em-dir-watcher/invokers/subprocess_invoker.rb:42:in `block (2 levels) in ready_to_use!'
/Users/stephen/dev/ruby/src/gems/em/em-dir-watcher-git/lib/em-dir-watcher/invokers/subprocess_invoker.rb:42:in `each'
/Users/stephen/dev/ruby/src/gems/em/em-dir-watcher-git/lib/em-dir-watcher/invokers/subprocess_invoker.rb:42:in `block in ready_to_use!'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `call'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `run_machine'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `run'
test/test_monitor.rb:148:in `block in <class:TestMonitor>'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/shoulda-2.11.3/lib/shoulda/context.rb:382:in `call'
/Users/stephen/.rvm/gems/ruby-1.9.2-p180/gems/shoulda-2.11.3/lib/shoulda/context.rb:382:in `block in create_test_from_should_hash'
44 tests, 44 assertions, 4 failures, 2 errors, 0 skips
Test run options: --seed 10118
rake aborted!
Command failed with status (1): [/Users/stephen/.rvm/rubies/ruby-1.9.2-p180...]
(See full trace by running task with --trace)
The readme claims it needs RubyCocoa installed but it seems it really only just needs the integration that's already available in the system Ruby on 10.6:
file: lib/em-dir-watcher/platform/mac/rubycocoa_watcher.rb
require 'osx/foundation'
OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
This is what rb-fsevent fixes so it seems to me that both em-dir-watcher and fssm would work better using rb-fsevent.
The readme in em-dir-watcher claims about fssm:
FSSM rescans the entire directory tree on each change, so it has about 0.5 sec lag on average-sized projects. Em-dir-watcher only rescans the changed subdirectories (on all systems), and avoids rescanning subtrees on the systems that support non-subtree notifications (Mac, Linux). We'd love to see our
Tree
class used in fssm — this should be an easy change.
But looking at the source for fssm I'm not sure that's the case for Ruby, perhaps it is for the other platforms.
Travis Tilly (https://github.com/ttilley) is the author for both rb-fsevent and fssm and seems to have started integrating rb-fsevent into fssm:
See:
I like the Tilly's two projects are tested on multiple versions of Ruby.
The readme in em-dir-watcher also claims about fssm:
Also, fssm does not know anything about Event Machine, so has to be run in a separate process/thread even on the systems that are reactor-friendly (i.e. Linux). Em-dir-watcher uses
EM.watch
to listen to inotify events on Linux.
I've been reading about Event Machine for a while and think it's cool but haven't used it. Is using em important to be able to run kicker in the same process? I use kicker from the command line so this isn't an issue for me.
Lastly the readme in em-dir-watcher also claims about fssm:
Besides, both fssm and directory_watcher do not support exclusions, and thus will walk, update and keep the entire tree in memory including the subfolders you don't need. Em-dir-watcher never walks excluded subfolders, so you can exclude the stuff you don't need to watch to further improve the performance.
How useful is this?
I was wrong, Tilly is not the author of rb-fsevent (he has forked it and is integrating it into fssm).
Thibaud Guillaume-Gentil is the author of rb-fsevent.
The last commit to rb-fsevent is from Mar 30 2011.
The last commit to fssm is from Mar 21, 2011.
The last commit to em-dir-watcher is from Aug 2010 and there has been no response from the author to recent pull requests
Tilly added to rb-fsevent while working on this fssm issue rb-fsevent backend can only monitor a single path at a time.
Thibaud pulled Tilly's changes into rb-fsevent.
I like the way Tilly is working on fssm and how responsive Thibaud is to pull requests.
In fact, only the “rescans the entire directory tree on each change” is important for Kicker, by using FSEvents it's unlikely that code would do that and I haven't seen it either, although I just skimmed through the code.
So I agree that FSSM with rb-fsevent seems the best option. Thanks for the investigation!
The new release of Kicker now uses rb-fsevent as an fsevent backend. Euruko was too short to also switch to a pure Ruby Growl implementation. I've created a new ticket for this: #16.
Thanks Manfred, kicker is working well on ruby-1.9.2-p180 now for me.