Giter Site home page Giter Site logo

rb-fsevent's Introduction

Code Climate Maintainability endorse

rb-fsevent

Very simple & usable Mac OSX FSEvents API

  • Signals are working (really)
  • Tested on MRI 2.4.1, RBX 3.72, JRuby 1.7.26 and 9.1.8.0
  • Tested on 10.8

HFS+ filename corruption bug

There is a very long-standing (since 2011) OSX bug where sometimes the filename metadata for HFS+ filesystems will get corrupted, resulting in some APIs returning one case for a file, and other APIs returning another. The result is that sometimes, for no visible reason to the user, fsevents would simply not work. As of rb-fsevent 0.9.5 this issue is properly detected and an insanely hacky (but effective) workaround is used that replaces the system realpath() with a custom implementation that should almost always return the same value as the kernel reporting (thus fixing fsevents). The major flaw in the workaround is that it may return the wrong path for hard links.

Please note that this doesn't repair the underlying issue on disk. Other apps and libraries using fsevents will continue to break with no warning. There may be other issues unrelated to fsevents.

This bug is resolved in MacOS 10.12 and all users are strongly encouraged to upgrade.

Install

gem install rb-fsevent

re-compilation

rb-fsevent comes with a pre-compiled fsevent_watch binary supporting x86_64 on 10.9 and above. The binary is codesigned with my (Travis Tilley) Developer ID as an extra precaution when distributing pre-compiled code and contains an embedded plist describing its build environment. This should be sufficient for most users, but if you need to use rb-fsevent on 10.8 or lower then recompilation is necessary. This can be done by entering the installed gem's ext directory and running:

MACOSX_DEPLOYMENT_TARGET="10.7" rake replace_exe

The following ENV vars are recognized:

  • CC
  • CFLAGS
  • ARCHFLAGS
  • MACOSX_DEPLOYMENT_TARGET
  • FWDEBUG (enables debug mode, printing an obscene number of informational messages to STDERR)

embedded plist

You can retrieve the values in the embedded plist via the CLI:

fsevent_watch --show-plist

The output is essentially formatted as "#{key}:\n #{value}\n" to make it easier to read than plist style xml. The result looks like this:

DTSDKName:
  macosx10.5
FSEWBuildTriple:
  i386-apple-darwin10.8.0
FSEWCC:
  /usr/bin/gcc-4.2
DTSDKPath:
  /Developer/SDKs/MacOSX10.5.sdk
FSEWCCVersion:
  i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
FSEWCFLAGS:
  -fconstant-cfstrings -fno-strict-aliasing -Wall -mmacosx-version-min=10.5 -O3

If, for some perverse reason, you prefer to look at the xml... it can be retrieved via:

otool -s __TEXT __info_plist ./bin/fsevent_watch | grep ^0 | xxd -r -

codesign

You can verify code signing information for a specific fsevent_watch via:

codesign -d -vvv ./bin/fsevent_watch

If you're using the pre-compiled binary, then the output should contain something to the effect of:

Authority=Developer ID Application: Travis Tilley
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=Dec 31, 2012 12:49:13 PM

Usage

Singular path

require 'rb-fsevent'

fsevent = FSEvent.new
fsevent.watch Dir.pwd do |directories|
  puts "Detected change inside: #{directories.inspect}"
end
fsevent.run

Multiple paths

require 'rb-fsevent'

paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd]

fsevent = FSEvent.new
fsevent.watch paths do |directories|
  puts "Detected change inside: #{directories.inspect}"
end
fsevent.run

Multiple paths and additional options as a Hash

require 'rb-fsevent'

paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd]
options = {:latency => 1.5, :no_defer => true }

fsevent = FSEvent.new
fsevent.watch paths, options do |directories|
  puts "Detected change inside: #{directories.inspect}"
end
fsevent.run

Multiple paths and additional options as an Array

require 'rb-fsevent'

paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd]
options = ['--latency', 1.5, '--no-defer']

fsevent = FSEvent.new
fsevent.watch paths, options do |directories|
  puts "Detected change inside: #{directories.inspect}"
end
fsevent.run

Using full event information

require 'rb-fsevent'
fsevent = FSEvent.new
fsevent.watch Dir.pwd do |paths, event_meta|
  event_meta['events'].each do |event|
    puts "event ID: #{event['id']}"
    puts "path: #{event['path']}"
    puts "c flags: #{event['cflags']}"
    puts "named flags: #{event['flags'].join(', ')}"
    # named flags will include strings such as `ItemInodeMetaMod` or `OwnEvent`
  end
end
fsevent.run

Options

When defining options using a hash or hash-like object, it gets checked for validity and converted to the appropriate fsevent_watch commandline arguments array when the FSEvent class is instantiated. This is obviously the safest and preferred method of passing in options.

You may, however, choose to pass in an array of commandline arguments as your options value and it will be passed on, unmodified, to the fsevent_watch binary when called.

So far, the following options are supported:

  • :latency => 0.5 # in seconds
  • :no_defer => true
  • :watch_root => true
  • :since_when => 18446744073709551615 # an FSEventStreamEventId
  • :file_events => true

Latency

The :latency parameter determines how long the service should wait after the first event before passing that information along to the client. If your latency is set to 4 seconds, and 300 changes occur in the first three, then the callback will be fired only once. If latency is set to 0.1 in the exact same scenario, you will see that callback fire somewhere closer to between 25 and 30 times.

Setting a higher latency value allows for more effective temporal coalescing, resulting in fewer callbacks and greater overall efficiency... at the cost of apparent responsiveness. Setting this to a reasonably high value (and NOT setting :no_defer) is particularly well suited for background, daemon, or batch processing applications.

Implementation note: It appears that FSEvents will only coalesce events from a maximum of 32 distinct subpaths, making the above completely accurate only when events are to fewer than 32 subpaths. Creating 300 files in one directory, for example, or 30 files in 10 subdirectories, but not 300 files within 300 subdirectories. In the latter case, you may receive 31 callbacks in one go after the latency period. As this appears to be an implementation detail, the number could potentially differ across OS revisions. It is entirely possible that this number is somehow configurable, but I have not yet discovered an accepted method of doing so.

NoDefer

The :no_defer option changes the behavior of the latency parameter completely. Rather than waiting for $latency period of time before sending along events in an attempt to coalesce a potential deluge ahead of time, that first event is sent along to the client immediately and is followed by a $latency period of silence before sending along any additional events that occurred within that period.

This behavior is particularly useful for interactive applications where that feeling of apparent responsiveness is most important, but you still don't want to get overwhelmed by a series of events that occur in rapid succession.

WatchRoot

The :watch_root option allows for catching the scenario where you start watching "/src/demo_project" and either it is later renamed to "/src/awesome_sauce_3000" or the path changes in such a manner that the original directory is now at "~/clients/foo/iteration4/demo_project".

Unfortunately, while this behavior is somewhat supported in the fsevent_watch binary built as part of this project, support for passing across detailed metadata is not (yet). As a result, you would not receive the appropriate RootChanged event and be able to react appropriately. Also, since the C code doesn't open watched directories and retain that file descriptor as part of path-specific callback metadata, we are unable to issue an F_GETPATH fcntl() to determine the directory's new path.

Please do not use this option until proper support is added (or, even better, add it and submit a pull request).

SinceWhen

The FSEventStreamEventId passed in to :since_when is used as a base for reacting to historic events. Unfortunately, not only is the metadata for transitioning from historic to live events not currently passed along, but it is incorrectly passed as a change event on the root path, and only per-host event streams are currently supported. When using per-host event streams, the event IDs are not guaranteed to be unique or contiguous when shared volumes (firewire/USB/net/etc) are used on multiple macs.

Please do not use this option until proper support is added, unless it's acceptable for you to receive that one fake event that's handled incorrectly when events transition from historical to live. Even in that scenario, there's no metadata available for determining the FSEventStreamEventId of the last received event.

WARNING: passing in 0 as the parameter to :since_when will return events for every directory modified since "the beginning of time".

FileEvents

Prepare yourself for an obscene number of callbacks. Realistically, an "Atomic Save" could easily fire maybe 6 events for the combination of creating the new file, changing metadata/permissions, writing content, swapping out the old file for the new may itself result in multiple events being fired, and so forth. By the time you get the event for the temporary file being created as part of the atomic save, it will already be gone and swapped with the original file. This and issues of a similar nature have prevented me from adding the option to the ruby code despite the fsevent_watch binary supporting file level events for quite some time now. Mountain Lion seems to be better at coalescing needless events, but that might just be my imagination.

Debugging output

If the gem is re-compiled with the environment variable FWDEBUG set, then fsevent_watch will be built with its various DEBUG sections defined, and the output to STDERR is truly verbose (and hopefully helpful in debugging your application and not just fsevent_watch itself). If enough people find this to be directly useful when developing code that makes use of rb-fsevent, then it wouldn't be hard to clean this up and make it a feature enabled by a commandline argument instead. Until somebody files an issue, however, I will assume otherwise.

append_path called for: /tmp/moo/cow/
  resolved path to: /private/tmp/moo/cow

config.sinceWhen    18446744073709551615
config.latency      0.300000
config.flags        00000000
config.paths
  /private/tmp/moo/cow

FSEventStreamRef @ 0x100108540:
   allocator = 0x7fff705a4ee0
   callback = 0x10000151e
   context = {0, 0x0, 0x0, 0x0, 0x0}
   numPathsToWatch = 1
   pathsToWatch = 0x7fff705a4ee0
        pathsToWatch[0] = '/private/tmp/moo/cow'
   latestEventId = -1
   latency = 300000 (microseconds)
   flags = 0x00000000
   runLoop = 0x0
   runLoopMode = 0x0

FSEventStreamCallback fired!
  numEvents: 32
  event path: /private/tmp/moo/cow/1/a/
  event flags: 00000000
  event ID: 1023767
  event path: /private/tmp/moo/cow/1/b/
  event flags: 00000000
  event ID: 1023782
  event path: /private/tmp/moo/cow/1/c/
  event flags: 00000000
  event ID: 1023797
  event path: /private/tmp/moo/cow/1/d/
  event flags: 00000000
  event ID: 1023812
  [etc]

Development

Pull requests are quite welcome! Please ensure that your commits are in a topic branch for each individual changeset that can be reasonably isolated. It is also important to ensure that your changes are well tested... whether that means new tests, modified tests, or fixing a scenario where the existing tests currently fail. If you have rbenv and ruby-build, we have a helper task for running the testsuite in all of them:

rake spec:portability

The list of tested targets is currently:

%w[2.4.1 rbx-3.72 jruby-1.7.26 jruby-9.1.8.0]

Authors

rb-fsevent's People

Contributors

acant avatar anatol avatar benhoskings avatar danielmorrison avatar dbussink avatar dskecse avatar greysteil avatar ioquatix avatar jdewind avatar kevintom avatar maher4ever avatar meeech avatar prepor avatar richardkmichael avatar saluzafa avatar skull-squadron avatar thibaudgg avatar ttilley avatar tyler-ball avatar vfrride avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rb-fsevent's Issues

Support for symlinked directories

Imagine the following directories structure:

/home
  --/projects
       --/dir_a
           -- symlink_to_dir_b
       --/dir_b
           -- dir_b_file

If I do:

fsevent.watch "/home/projects/dir_a" do |directories|
  puts "Detected change inside: #{directories.inspect}"
end

And I change the /home/projects/dir_b/dir_b_file, isn't a callback supposed to run?

Running worker failed error after rails server started

Stack:
Ruby 2.4.1
Rails 5.1.2

Error:

E, [2017-06-30T17:51:34.978441 #83263] ERROR -- : fsevent: running worker failed: wrong number of arguments (given 2, expected 1):/Users/shala/.rvm/gems/ruby-2.4.1/gems/listen-3.1.5/lib/listen/adapter/base.rb:41:in `block (2 levels) in configure'
/Users/shala/.rvm/gems/ruby-2.4.1/gems/rb-fsevent-0.10.1/lib/rb-fsevent/fsevent.rb:75:in `run'
/Users/shala/.rvm/gems/ruby-2.4.1/gems/listen-3.1.5/lib/listen/adapter/darwin.rb:71:in `_run_worker'
/Users/shala/.rvm/gems/ruby-2.4.1/gems/listen-3.1.5/lib/listen/adapter/darwin.rb:55:in `_run'
/Users/shala/.rvm/gems/ruby-2.4.1/gems/listen-3.1.5/lib/listen/adapter/base.rb:78:in `block in start'
/Users/shala/.rvm/gems/ruby-2.4.1/gems/listen-3.1.5/lib/listen/internals/thread_pool.rb:6:in `block in add' called from: /Users/shala/.rvm/gems/ruby-2.4.1/gems/listen-3.1.5/lib/listen/adapter/darwin.rb:70:in `_run_worker'
/Users/shala/.rvm/gems/ruby-2.4.1/gems/listen-3.1.5/lib/listen/adapter/darwin.rb:55:in `_run'
/Users/shala/.rvm/gems/ruby-2.4.1/gems/listen-3.1.5/lib/listen/adapter/base.rb:78:in `block in start'
/Users/shala/.rvm/gems/ruby-2.4.1/gems/listen-3.1.5/lib/listen/internals/thread_pool.rb:6:in `block in add'

Unexpected EOF when watching (first call)

sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file

Code is practically identical with the sample. What info more do you need from me to troubleshoot this?

Renaming a folder to a different case makes event not fire

I'm using rb-fsevent in OS X Lion through the guard gem (this issue might be on guard's end but I'm starting here).

If you mv a folder foo to Foo the events will not fire anymore for any file within this folder. Renaming the folder corrects the issue.

handling of multiple paths

Hello!!

In order to bypass the limitations of ruby 1.8, green threads, blocking IO, and having a singular "run loop" (because of the above)... I need for rb-fsevent to support the watching of multiple paths without having to spawn multiple watcher processes. I've started a fork where I can play around with this idea, and would like some input on whether you think this is the right approach for rb-fsevent.

Since it's still a singular watcher process with a singular callback back into the library, it would be painful to watch multiple paths and give each their own callback within rb-fsevent itself. There would be way too much handling of state, which would kill the nice clean directness of the library. I believe this is an acceptable limitation, and one that's made a bit more intuitive by continuing to have the singular FSEvent instance. This is also something I'd like your input on.

The relevant issue in FSSM (which optionally uses rb-fsevent as a backend) is here: https://github.com/ttilley/fssm/issues#issue/23

Change to the C code in fsevent_watch: ttilley@47c6602

An idea about changes to the ruby code that handles the child process: ttilley@b02063e

Coordinated rename of gems

Hi fellow maintainers.

I've recently assumed maintainership of rb-inotify and I'm looking to bring it to 1.0 in the next few months.

I'd like to coordinate with you on this process.

There are three main points I think we should discuss initially

  • Shared test suite - these gems do essentially the same thing on different hardware. What about a shared test suite? e.g. this file is created, was it detected? May require some common high level interface.

  • Renaming the gems. rb-inotify is a poor name. I'm not sure what is better, but I'm thinking it may make sense to nest it within FFI, e.g. ffi-inotify and ffi-fsevent. Thoughts? Ideas? We can keep backwards compatibility - we can make a 1.0 release which includes a compatibility layer for the new ffi- variants. This might also require some involvement from the listen gem authors/maintainers.

  • Shared organisation - I've been trying to contact someone within the guard organisation. I think it would make sense for some kind of shared maintainership. We could either try to go down that road with guard or we could simply create our own org and move all code into it.

single quote in a file name

This package creats a gem that has a directory not only with a space, bad news for Linuxs user, but also has a single quote in it:
/usr/local/share/gems/gems/rb-fsevent-0.9.6/spec/fixtures/custom*

This gem was auto installed when I installed a jekyll theme.

I am fairly certain it is yours:
/usr/local/share/gems/gems/rb-fsevent-0.9.6//README.md
https://codeclimate.com/badge.png)](https://codeclimate.com/github/thibaudgg/rb-fsevent)
https://api.coderwall.com/ttilley/endorsecount.png)](https://coderwall.com/ttilley)

rb-fsevents does not work with guard (possibly from unicode chars in path)

Hi, i just installed rb-fsevents to supress guard warning message and it stopped firing events. Without rb-fsevents all works ok.
I've installed rb-fsevents with debug options and here is output:

Guard is now watching at '/Users/mikz/Dropbox/documents/Škola/BP'

append_path called for: /Users/mikz/Dropbox/documents/Škola/BP
resolved path to: /Users/mikz/Dropbox/Documents/Škola/BP

config.sinceWhen 18446744073709551615
config.latency 0.300000
config.flags 00000000
config.paths
/Users/mikz/Dropbox/Documents/Škola/BP

FSEventStreamRef @ 0x100108640:
allocator = 0x7fff7013dee0
callback = 0x100001522
context = {0, 0x0, 0x0, 0x0, 0x0}
numPathsToWatch = 1
pathsToWatch = 0x7fff7013dee0
pathsToWatch[0] = '/Users/mikz/Dropbox/Documents/Škola/BP'
latestEventId = -1
latency = 300000 (microseconds)
flags = 0x00000000
runLoop = 0x0
runLoopMode = 0x0

No more logs or events even I repeatedly saved multiple files in directory (from TextMate with atomic saves off and on)

Maybe its problem with unicode chars in path?

Ctrl-C behaviour?

Hi,

When entering fsevent.run, if the user hits ctrl-c the exception is not propagated as one might expect.

Expected when user press ctrl-c or process killed with sigint, that fsevent.run would internally raise Interrupt.

Actual result: fsevent.run returns with no special information about interrupt.

os x 10.8 no events are firing

I have the following test code:

require 'rb-fsevent'

dir = File.expand_path '../..', __FILE__

fsevent = FSEvent.new
fsevent.watch dir do |directories|
  puts "Detected change inside: #{directories.inspect}"
end
fsevent.run

If I do a 'touch' inside the directory that contains the script, I don't get any output.

rb-fsevent: 0.9.3
ruby 1.9.3-p286
OSX 10.8.2
RVM 1.17.7

No events get fired

I found out about this issue via guard/listen: see this issue

OS X 10.8.2, various Rubies tested.

When I run a simple script for rb-fsevent (the first one from the readme), I get no errors, but no events get fired.

When I checkout rb-fsevent and try to run the specs, I get an error, but the specs pass anyway:

> bundle exec rspec
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}
Build settings from configuration file '/Users/meurkens/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/rb-fsevent-a80be21b94ba/ext/rb-fsevent.xcconfig':
    ARCHS = $(NATIVE_ARCH_ACTUAL)
    DEAD_CODE_STRIPPING = YES
    DSTROOT = ../../
    GCC_C_LANGUAGE_STANDARD = gnu99
    GCC_ENABLE_EXCEPTIONS = YES
    GCC_ENABLE_OBJC_EXCEPTIONS = YES
    GCC_ENABLE_OBJC_GC = unsupported
    GCC_GENERATE_DEBUGGING_SYMBOLS = YES
    GCC_VERSION = com.apple.compilers.llvm.clang.1_0
    INSTALL_MODE_FLAG = u+w,go-w,a+rX
    INSTALL_PATH = /bin
    LD_NO_PIE = NO
    LLVM_LTO = NO
    MACOSX_DEPLOYMENT_TARGET = 10.5
    OBJROOT = $(SYMROOT)
    PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES
    RUN_CLANG_STATIC_ANALYZER = YES
    SDKROOT = 
    SKIP_INSTALL = NO
    SYMROOT = build

=== CLEAN NATIVE TARGET fsevent_watch OF PROJECT fsevent_watch WITH CONFIGURATION Release ===
Check dependencies
[BEROR]Code Sign error: The identity '3rd Party Mac Developer Application: Travis Tilley' doesn't match any valid, non-expired certificate/private key pair in your keychains

Clean.Remove clean build/fsevent_watch.build/Release/fsevent_watch.build
    builtin-rm -rf /Users/meurkens/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/rb-fsevent-a80be21b94ba/ext/fsevent_watch/build/fsevent_watch.build/Release/fsevent_watch.build

Clean.Remove clean build/Release/fsevent_watch
    builtin-rm -rf /Users/meurkens/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/rb-fsevent-a80be21b94ba/ext/fsevent_watch/build/Release/fsevent_watch


** CLEAN SUCCEEDED **

** BUILD FAILED **


The following build commands failed:
    Check dependencies
(1 failure)
Build settings from configuration file '/Users/meurkens/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/rb-fsevent-a80be21b94ba/ext/rb-fsevent.xcconfig':
    ARCHS = $(NATIVE_ARCH_ACTUAL)
    DEAD_CODE_STRIPPING = YES
    DSTROOT = ../../
    GCC_C_LANGUAGE_STANDARD = gnu99
    GCC_ENABLE_EXCEPTIONS = YES
    GCC_ENABLE_OBJC_EXCEPTIONS = YES
    GCC_ENABLE_OBJC_GC = unsupported
    GCC_GENERATE_DEBUGGING_SYMBOLS = YES
    GCC_VERSION = com.apple.compilers.llvm.clang.1_0
    INSTALL_MODE_FLAG = u+w,go-w,a+rX
    INSTALL_PATH = /bin
    LD_NO_PIE = NO
    LLVM_LTO = NO
    MACOSX_DEPLOYMENT_TARGET = 10.5
    OBJROOT = $(SYMROOT)
    PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES
    RUN_CLANG_STATIC_ANALYZER = YES
    SDKROOT = 
    SKIP_INSTALL = NO
    SYMROOT = build

=== ANALYZE NATIVE TARGET fsevent_watch OF PROJECT fsevent_watch WITH CONFIGURATION Release ===
Check dependencies
Code Sign error: The identity '3rd Party Mac Developer Application: Travis Tilley' doesn't match any valid, non-expired certificate/private key pair in your keychains


rake aborted!
xcodebuild failure
Tasks: TOP => default => xcode:install => xcode:build
(See full trace by running task with --trace)
fsevent_watch compiled
.......

Finished in 15.35 seconds
7 examples, 0 failures

Thanks a lot!

Build fails on OS X Mountain Lion

I have OS 10.8 installed (along with XCode and the Command Line Utilities) and the build is failing with the following

$ gem install rb-fsevent -v '0.4.3.1'
Building native extensions.  This could take a while...
ERROR:  Error installing rb-fsevent:
    ERROR: Failed to build gem native extension.

        /Users/jared/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
creating Makefile
extconf.rb:21:in `<main>': Only Darwin systems greater than 8 (Mac OS X 10.5+) are supported (RuntimeError)

rb-fsevent taking up over 100% CPU

I'm running guard in my Rails app and the test suite has recently stopped running smoothly.
If I'm lucky, it'll run all of the tests once, maybe twice. After that, it takes so long to respond to even one small test file being changed that
using the gem becomes futile.

When following top while the tests run, I can see there's a ruby process that's taking up over 100% of the CPU constantly. Even once all tests are run and I haven't made any changes to the file.

screen shot 2013-12-03 at 17 52 51

The ruby process is:

/Users/Bodacious/.rvm/gems/ruby-2.0.0-p247@MyApp/gems/rb-fsevent-0.9.3/bin/fsevent_watch --latency 0.1 /Users/Bodaiou/Clients/MyApp

(process 31332) in the screenshot attached.

Here's my setup:

Gemfile

group :test do
  gem 'launchy'
  gem "mocha", require: false
  gem 'database_cleaner'
  gem 'selenium-webdriver'
  gem 'capybara-webkit' # for headless javascript tests
  gem 'timecop'
  gem "minitest-focus"
end

group :development, :test do
  gem "minitest-rails"
  gem "minitest-rails-capybara"
  gem 'zeus'
  gem 'guard'
  gem 'guard-minitest'
  gem 'factory_girl_rails'
end

Guardfile

guard :minitest, all_on_start: false do
  # Rails 4
  watch(%r{^app/(.+)\.rb})                               { |m| "test/#{m[1]}_test.rb" }
  watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' }
  watch(%r{^app/controllers/(.+)_controller\.rb})        { |m| "test/integration/#{m[1]}_test.rb" }
  watch(%r{^app/views/(.+)_mailer/.+})                   { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
  watch(%r{^lib/(.+)\.rb})                               { |m| "test/lib/#{m[1]}_test.rb" }
  watch(%r{^test/.+_test\.rb})
  watch(%r{^test/test_helper\.rb})                       { 'test' }

  ignore(%r{^tmp/})

end

test_helper

ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)

require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/pride'
require "minitest/rails/capybara"

require "mocha/setup"

# Sidekiq https://github.com/mperham/sidekiq/wiki/Testing
require 'sidekiq/testing'
Sidekiq::Testing.fake!

Dir[Rails.root.join('test', 'support', '*.rb')].each do |file|
  require file
end


class MiniTest::Spec
  include FactoryGirl::Syntax::Methods
  include AllTestHelper

end


class ActiveSupport::TestCase
  include FactoryGirl::Syntax::Methods
  include AllTestHelper
end

class Capybara::Rails::TestCase
  include Rails.application.routes.url_helpers 
  include Capybara::DSL
  include Capybara::Assertions
  include IntegrationTestHelper

  # Called before each Feature spec
  before :each do
  end

  # Called after each Feature spec
  after :each do
    Capybara.reset_sessions!
  end
end

Gem Versions:

  • minitest (4.7.5)
  • minitest-capybara (0.5.0)
  • minitest-focus (1.1.0)
  • minitest-metadata (0.4.0)
  • minitest-rails (0.9.2)
  • minitest-rails-capybara (0.10.0)
  • mobvious-rails (0.1.2)
  • mocha (0.14.0)
  • guard (2.2.4)
  • guard-minitest (2.1.2)
  • rb-fsevent (0.9.3)

Any advise on where to look to start fixing this?

rb-fsevent 0.9.8 specs warnings

When I've updated to 0.9.8 though bundle, jekyll tells me as follows:

WARN: Unresolved specs during Gem::Specification.reset:
rb-fsevent (>= 0.9.3)
WARN: Clearing out unresolved specs.

I've tried to reinstall rb-fsevent through gem, but it still refuses to work.

register_with_server: ERROR

I am using rails, guard, fb-fsevent on Mac OSX to trigger rspec when I change a test or code. It works well, but I often get the following sort of message

fsevent_watch[4227] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR:    f2d_register_rpc() => (null) (-21)
when I start guard with bundle exec guard.

I can often fix this by closing a couple of unneeded applications, but in the end I have to reboot the system. It appears to be caused by watching too many files, so as my application grows it becomes worse. Any suggestions on how to fix this? The relevant version numbers are:

rails 4.2.0, guard 2.6.1, fb-fsevent 0.9.1 on Mac OSX 10.10.1. I have asked this question on stackoverflow here but have received no answer.

Deletes not triggering over AFP

I've got a shared drive (AFP) that I'm tracking changes on. Say I copy in a folder with images in it to the shared folder, when the folder is deleted from another computer via finder (on the shared drive over AFP), I get a deleted event for all files, but not for the folder that contained them (and was also deleted). Any ideas why this might be?

Thanks

Include Gemfile hints

Wouldn't be a good idea to write in the README a suggestion on how to include the gem in the Gemfile?

The problem exists in multi-platform configurations, as it's not unusual to develop on OS X machines and deploy on Linux ones. We don't want Bundler to try to install rb-fsevent on Linux.

For example, I used:

gem 'rb-fsevent', install_if: ->() { `uname` =~ /darwin/i }

(And by the way, do you think this is a good approach?)

Thanks!

Installing without Xcode using OSX GCC Installer

I've been trying to ditch Xcode for the OSX GCC Installer (https://github.com/kennethreitz/osx-gcc-installer) and rb-fsevent is the only standing between me and victory. I uninstalled Xcode and then tried installing rb-fsevent and got the following error. Is this a lost cause or is there potentially a workaround to get it to compile without Xcode?

Installing rb-fsevent (0.4.3) with native extensions /Users/portia/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:551:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /Users/portia/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
creating Makefile
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -Os -pipe -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow -Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion -Wshorten-64-to-32 -Wglobal-constructors -pedantic' /usr/bin/clang -isysroot /Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -dead_strip -framework CoreServices -o '/Users/portia/.rvm/gems/ruby-1.9.2-p290@sentalis4/gems/rb-fsevent-0.4.3/bin/fsevent_watch' fsevent/fsevent_watch.c
fsevent/fsevent_watch.c:1:10: fatal error: 'stdio.h' file not found
#include 
         ^
1 error generated.
extconf.rb:59:in `': Compilation of fsevent_watch failed (see README) (RuntimeError)

OSX 10.9 Maverick

API diff mentions:

FSEvents.h
Added FSEventStreamSetExclusionPaths()
Added kFSEventStreamCreateFlagMarkSelf
Added kFSEventStreamEventFlagOwnEvent

Exclusion paths? THAT sounds pretty damn handy. I'll be installing 10.9 on a play partition tonight or tomorrow to poke around.

xcode build issues when running the test suite

Running the suite seems to depend on a certificate that's specific to your machine:

[BEROR]Code Sign error: The identity '3rd Party Mac Developer Application: Travis Tilley' doesn't match any valid certificate/private key pair in the default keychain

This causes bin/fsevent to be deleted, but the current spec run succeeds (presumably because the file is already open); subsequent runs fail until it's restored with git checkout.

File changes are not detected

I'm trying to set up a testing environment with rspec and guard for a rails project, but seems that rb-fsevent is not detecting any changes in my file system.

Without rb-fsevent guard is working properly(using polling), but with rb-fsevent guard is simply not detecting those changes.

I tried to launch rb-fsevent separately in console with a simple code:
fsevent = FSEvent.new
fsevent.watch Dir.pwd do |directory|
p "Detected change inside #{directory.inspect}"
end
fsevent.run
but modifying and saving any files results in silence.

I'm on Mac OS X 10.6.6 running ruby-1.9.2 through RVM.
I tried previous versions (0.3.8 and 0.3.6) and still no luck :(

Do you need any other info on this issue?

Cannot handle directories with colons in their name

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 (:\:, \\\).

Abstract out ext/fsevent_watch code to separate repo

Any chance you guys would want to abstract out the Xcode project to a standalone repo so it could be used easily with node.js as well? That would be really helpful.

The node.js watcher use kqueue which is really slow on large directories, but rb-fsevent seems to be very fast. I am currently just streaming the output from a simple ruby script that gets spawned from node.js, like this:

It would be awesome if your C fsevent code could be used in node.js without requiring ruby. Let me know if there's anything I can do to help make this happen, I don't know C but am definitely willing to learn.

Doesn't catch SIGQUIT

I experience this routinely when used in combination with guard. I'll activate a full test suite run using ^\ on the console to send SIGQUIT and then the OS crash reporter will open saying fsevent_watch has quit unexpectedly due to uncaught SIGQUIT.

Receiving SIGQUIT crashes entire windowserver

There's a bug in macOS 10.12.4, that manifests like this: when fsevent_watch receives a SIGQUIT it (either directly or indirectly I'm not sure) crashes the WindowServer, which takes all gui applications down with it.

I'm going to write this up for Apple too, but since they are often slow to fix things and this will continue to affect anyone on 10.12.4 (possibly other versions, I'm not fond of triggering the bug to test it obviously).

Let me know if there's more info you'd like me to provide.

Show file names

rb-fsevent shows only a directory of the file that has been changed.

require 'rb-fsevent'

fsevent = FSEvent.new
fsevent.watch '/tmp' do |directories|
  puts "Detected change inside: #{directories.inspect}"
end
fsevent.run


➤ touch /tmp/test


Detected change inside: ["/private/tmp/"]

Is it possible to make rb-fsevent show also file names?

Problems running watcher in a thread

I have a test that starts a watcher in a thread (via guard/listen), sleeps, and then makes a file change that the watcher should pick up.

About 90% of the time, it appears that the watcher never even gets set up, for some reason I can't determine.

However, when it does get set up, it never terminates. The fsevent_watch process remains running even after I have killed the thread. This means that my Ruby process also remains running.

What is the proper way to ensure termination of that process (and thereby my Ruby process)?

Thanks for any help you can provide.

Events not firing

I'm trying to pin down exactly what's happening here. The specs don't pass, I ran it in debug mode:

creating Makefile
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -mdynamic-no-pic -std=gnu99 -Os -pipe -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow -Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion -Wshorten-64-to-32 -Wglobal-constructors -pedantic' /usr/bin/gcc -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -mdynamic-no-pic -std=gnu99 -dead_strip -framework CoreServices -D DEBUG=true -o '/users/dave/code/temp/rb-fsevent/bin/fsevent_watch' fsevent/fsevent_watch.c
fsevent_watch compiled
.
append_path called for: /users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path
  resolved path to: /Users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path

config.sinceWhen    18446744073709551615
config.latency      0.300000
config.flags        00000000
config.paths
  /Users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path

FSEventStreamRef @ 0x1001085c0:
   allocator = 0x7fff709faee0
   callback = 0x100001522
   context = {0, 0x0, 0x0, 0x0, 0x0}
   numPathsToWatch = 1
   pathsToWatch = 0x7fff709faee0
        pathsToWatch[0] = '/Users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path'
   latestEventId = -1
   latency = 300000 (microseconds)
   flags = 0x00000000
   runLoop = 0x0
   runLoopMode = 0x0

F
append_path called for: /users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path
  resolved path to: /Users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path

config.sinceWhen    18446744073709551615
config.latency      0.300000
config.flags        00000000
config.paths
  /Users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path

FSEventStreamRef @ 0x1001085c0:
   allocator = 0x7fff709faee0
   callback = 0x100001522
   context = {0, 0x0, 0x0, 0x0, 0x0}
   numPathsToWatch = 1
   pathsToWatch = 0x7fff709faee0
        pathsToWatch[0] = '/Users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path'
   latestEventId = -1
   latency = 300000 (microseconds)
   flags = 0x00000000
   runLoop = 0x0
   runLoopMode = 0x0


append_path called for: /users/dave/code/temp/rb-fsevent/spec/fixtures
  resolved path to: /Users/dave/code/temp/rb-fsevent/spec/fixtures

config.sinceWhen    18446744073709551615
config.latency      0.500000
config.flags        00000000
config.paths
  /Users/dave/code/temp/rb-fsevent/spec/fixtures

FSEventStreamRef @ 0x1001085e0:
   allocator = 0x7fff709faee0
   callback = 0x100001522
   context = {0, 0x0, 0x0, 0x0, 0x0}
   numPathsToWatch = 1
   pathsToWatch = 0x7fff709faee0
        pathsToWatch[0] = '/Users/dave/code/temp/rb-fsevent/spec/fixtures'
   latestEventId = -1
   latency = 500000 (microseconds)
   flags = 0x00000000
   runLoop = 0x0
   runLoopMode = 0x0

F
append_path called for: /users/dave/code/temp/rb-fsevent/spec/fixtures
  resolved path to: /Users/dave/code/temp/rb-fsevent/spec/fixtures

config.sinceWhen    18446744073709551615
config.latency      0.500000
config.flags        00000000
config.paths
  /Users/dave/code/temp/rb-fsevent/spec/fixtures

FSEventStreamRef @ 0x1001085e0:
   allocator = 0x7fff709faee0
   callback = 0x100001522
   context = {0, 0x0, 0x0, 0x0, 0x0}
   numPathsToWatch = 1
   pathsToWatch = 0x7fff709faee0
        pathsToWatch[0] = '/Users/dave/code/temp/rb-fsevent/spec/fixtures'
   latestEventId = -1
   latency = 500000 (microseconds)
   flags = 0x00000000
   runLoop = 0x0
   runLoopMode = 0x0


append_path called for: /users/dave/code/temp/rb-fsevent/spec/fixtures
  resolved path to: /Users/dave/code/temp/rb-fsevent/spec/fixtures

config.sinceWhen    18446744073709551615
config.latency      0.500000
config.flags        00000000
config.paths
  /Users/dave/code/temp/rb-fsevent/spec/fixtures

FSEventStreamRef @ 0x1001085e0:
   allocator = 0x7fff709faee0
   callback = 0x100001522
   context = {0, 0x0, 0x0, 0x0, 0x0}
   numPathsToWatch = 1
   pathsToWatch = 0x7fff709faee0
        pathsToWatch[0] = '/Users/dave/code/temp/rb-fsevent/spec/fixtures'
   latestEventId = -1
   latency = 500000 (microseconds)
   flags = 0x00000000
   runLoop = 0x0
   runLoopMode = 0x0

F
append_path called for: /users/dave/code/temp/rb-fsevent/spec/fixtures
  resolved path to: /Users/dave/code/temp/rb-fsevent/spec/fixtures

config.sinceWhen    18446744073709551615
config.latency      0.500000
config.flags        00000000
config.paths
  /Users/dave/code/temp/rb-fsevent/spec/fixtures

FSEventStreamRef @ 0x1001085e0:
   allocator = 0x7fff709faee0
   callback = 0x100001522
   context = {0, 0x0, 0x0, 0x0, 0x0}
   numPathsToWatch = 1
   pathsToWatch = 0x7fff709faee0
        pathsToWatch[0] = '/Users/dave/code/temp/rb-fsevent/spec/fixtures'
   latestEventId = -1
   latency = 500000 (microseconds)
   flags = 0x00000000
   runLoop = 0x0
   runLoopMode = 0x0


append_path called for: /users/dave/code/temp/rb-fsevent/spec/fixtures
  resolved path to: /Users/dave/code/temp/rb-fsevent/spec/fixtures

config.sinceWhen    18446744073709551615
config.latency      0.500000
config.flags        00000000
config.paths
  /Users/dave/code/temp/rb-fsevent/spec/fixtures

FSEventStreamRef @ 0x1001085e0:
   allocator = 0x7fff709faee0
   callback = 0x100001522
   context = {0, 0x0, 0x0, 0x0, 0x0}
   numPathsToWatch = 1
   pathsToWatch = 0x7fff709faee0
        pathsToWatch[0] = '/Users/dave/code/temp/rb-fsevent/spec/fixtures'
   latestEventId = -1
   latency = 500000 (microseconds)
   flags = 0x00000000
   runLoop = 0x0
   runLoopMode = 0x0

F
append_path called for: /users/dave/code/temp/rb-fsevent/spec/fixtures
  resolved path to: /Users/dave/code/temp/rb-fsevent/spec/fixtures

config.sinceWhen    18446744073709551615
config.latency      0.500000
config.flags        00000000
config.paths
  /Users/dave/code/temp/rb-fsevent/spec/fixtures

FSEventStreamRef @ 0x1001085e0:
   allocator = 0x7fff709faee0
   callback = 0x100001522
   context = {0, 0x0, 0x0, 0x0, 0x0}
   numPathsToWatch = 1
   pathsToWatch = 0x7fff709faee0
        pathsToWatch[0] = '/Users/dave/code/temp/rb-fsevent/spec/fixtures'
   latestEventId = -1
   latency = 500000 (microseconds)
   flags = 0x00000000
   runLoop = 0x0
   runLoopMode = 0x0



Failures:

  1) FSEvent should work with path with an apostrophe
     Failure/Error: @results.should == [custom_path.to_s + '/']
       expected: ["/users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path/"]
            got: [] (using ==)
       Diff:
       @@ -1,2 +1,2 @@
       -["/users/dave/code/temp/rb-fsevent/spec/fixtures/custom 'path/"]
       +[]
     # ./spec/rb-fsevent/fsevent_spec.rb:30:in `block (2 levels) in <top (required)>'

  2) FSEvent should catch new file
     Failure/Error: @results.should == [@fixture_path.to_s + '/']
       expected: ["/users/dave/code/temp/rb-fsevent/spec/fixtures/"]
            got: [] (using ==)
       Diff:
       @@ -1,2 +1,2 @@
       -["/users/dave/code/temp/rb-fsevent/spec/fixtures/"]
       +[]
     # ./spec/rb-fsevent/fsevent_spec.rb:40:in `block (2 levels) in <top (required)>'

  3) FSEvent should catch file update
     Failure/Error: @results.should == [@fixture_path.join("folder1/").to_s]
       expected: ["/users/dave/code/temp/rb-fsevent/spec/fixtures/folder1/"]
            got: [] (using ==)
       Diff:
       @@ -1,2 +1,2 @@
       -["/users/dave/code/temp/rb-fsevent/spec/fixtures/folder1/"]
       +[]
     # ./spec/rb-fsevent/fsevent_spec.rb:49:in `block (2 levels) in <top (required)>'

  4) FSEvent should catch files update
     Failure/Error: @results.should == [@fixture_path.join("folder1/").to_s, @fixture_path.join("folder1/folder2/").to_s]
       expected: ["/users/dave/code/temp/rb-fsevent/spec/fixtures/folder1/", "/users/dave/code/temp/rb-fsevent/spec/fixtures/folder1/folder2/"]
            got: [] (using ==)
       Diff:
       @@ -1,3 +1,2 @@
       -["/users/dave/code/temp/rb-fsevent/spec/fixtures/folder1/",
       - "/users/dave/code/temp/rb-fsevent/spec/fixtures/folder1/folder2/"]
       +[]
     # ./spec/rb-fsevent/fsevent_spec.rb:61:in `block (2 levels) in <top (required)>'

Finished in 13.4 seconds
5 examples, 4 failures

I'm running ruby-1.9.2-p180
Mac OSX 10.6.6

I'm not sure what other information would be helpful. If i build the debug binary and run it on a directory i'm not seeing any events firing.

Any ideas?

perform proper deserialization

The fsevent_watch binary supports sending back detailed metadata as netstrings rather than the currently used, and incredibly limited, newline delimited and minimal data format. The ruby side of things should probably switch over at some point.

Perhaps use of ichannel would allow for some cheating here:
https://github.com/robgleeson/ichannel

Gem installs, but crashes guard process in JRuby

Hello,

I'm having an issue in a Rails API app, while trying to run guard.

I'm using JRuby 1.7.3, Rails API 3.2.13 and the latest guard-jruby-rspec (even the vanilla guard-rspec gives the same error).

I am linking in two gists, one detailing the Gemfile, Gemfile.lock and Guardfile and the other showing the stack trace both in regular mode and with Xnative.verbose flag on in JRuby.

https://gist.github.com/batasrki/5799894
https://gist.github.com/batasrki/5798620

Thanks

Can't install with Command Line Tools for XCode 4.3

I removed the bloated XCode (sudo /Developer/Library/uninstall-devtools –mode=all) in favor of Apple's "Command Line Tools for XCode 4.3" package.

But I get this errors when trying to install rb-fsevent.

$ gem install rb-fsevent -v '0.4.3.1'
Building native extensions.  This could take a while...
ERROR:  Error installing rb-fsevent:
    ERROR: Failed to build gem native extension.

        /usr/local/Cellar/ruby/1.9.3-p0/bin/ruby extconf.rb
creating Makefile
CFLAGS='-isysroot //SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -Os -pipe -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow -Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion -Wshorten-64-to-32 -Wglobal-constructors -pedantic' /usr/bin/clang -isysroot //SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -dead_strip -framework CoreServices -o '/usr/local/lib/ruby/gems/1.9.1/gems/rb-fsevent-0.4.3.1/bin/fsevent_watch' fsevent/fsevent_watch.c
fsevent/fsevent_watch.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.
extconf.rb:59:in `<main>': Compilation of fsevent_watch failed (see README) (RuntimeError)


Gem files will remain installed in /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rb-fsevent-0.4.3.1 for inspection.
Results logged to /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rb-fsevent-0.4.3.1/ext/gem_make.out

I used the xcode-select to witch the XCode path, and change it to /, since I could not find any /Developer/ ou /Developer/MacOSX10.7.sdk folder.

Compiling with Xcode 4.3

If you're an Apple developer and have access to the preview release of Xcode 4.3, you will find that this gem fails to compile 'fsevent/fsevent_watch.c' with the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing rb-fsevent:
    ERROR: Failed to build gem native extension.

        /Users/matt/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
creating Makefile
CFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -Os -pipe -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow -Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion -Wshorten-64-to-32 -Wglobal-constructors -pedantic' /usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -dead_strip -framework CoreServices -o '/Users/matt/.rvm/gems/ruby-1.9.3-p0/gems/rb-fsevent-0.4.3.1/bin/fsevent_watch' fsevent/fsevent_watch.c
fsevent/fsevent_watch.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.
extconf.rb:59:in `<main>': Compilation of fsevent_watch failed (see README) (RuntimeError)

I'm guessing it's due to the changes to install locations with Xcode 4.3.... (but don't have the time to look further into it at this point - sorry).

spec/fixtures includes garbage

drwxr-xr-x 3 jbegleiter staff 102 Aug  8 12:55 custom 'path
drwxr-xr-x 4 jbegleiter staff 136 Aug  8 13:04 folder1

./custom 'path:

./folder1:
-rw-r--r-- 1 jbegleiter staff   0 Aug  8 12:55 file1.txt
drwxr-xr-x 3 jbegleiter staff 102 Aug  8 13:04 folder2

./folder1/folder2:
-rw-r--r-- 1 jbegleiter staff 0 Aug  8 12:55 file2.txt

The single-quote in the name actually screws up my mvn package, which I've had to explicitly ignore

Randomly dying with Guard on Lion

I'm using this with guard on Lion and it keeps dying at seemingly random times. I'm also not sure when it does die until I don't see the growl message, e.g. I don't know if it dies at the end of file change trigger or at the start.

can't install on OSX lion

Output from trying to install are below any thoughts or directions would be great.

limeyd@~  (ruby-1.9.2-p180) 
% gem install rb-fsevent
Building native extensions.  This could take a while...
ERROR:  Error installing rb-fsevent:
    ERROR: Failed to build gem native extension.

        /Users/limeyd/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
creating Makefile
extconf.rb:15:in `<main>': Could not find a suitable Xcode installation (RuntimeError)


Gem files will remain installed in /Users/limeyd/.rvm/gems/ruby-1.9.2-p180/gems/rb-fsevent-0.4.3 for inspection.
Results logged to /Users/limeyd/.rvm/gems/ruby-1.9.2-p180/gems/rb-fsevent-0.4.3/ext/gem_make.out```

latest gem is slow

i use rb-fsevent for rego

https://github.com/ahoward/rego

after upgrading i was seeing extremely sluggish responses

i'm playing locally with the following config in an attempt to make the lib more reactive

   trap('SIGINT'){ exit!(42) }

    fsevent.watch(
      directories,
        :latency => 0.00042,
        :no_defer => true,
        :file_events => true,
        :watch_root => true,
        :since_when => 0
    ) do |*args|

      p :args => args

   end

but there seems to be some baked in max of about a second: i can't seem to process events faster than that....

i scanned the code and did not see anything obvious, so i thought i'd drop this in a ticket and ask for help

Can't install on 10.4.11: "Could not find a suitable Xcode installation"

I'm getting the same issue as the Lion user in another closed issue:

Installing rb-fsevent (0.4.3.1) with native extensions /Users/deveritt/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/Users/deveritt/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
creating Makefile
extconf.rb:15:in `

': Could not find a suitable Xcode installation (RuntimeError)

Fails to build undler OS X Lion (last XCode), ruby 1.9.3-p194

but this one is ok under ruby 1.9.3-p125

gem install rb-fsevent -v '0.4.3.1'
Building native extensions. This could take a while...
ERROR: Error installing rb-fsevent:
ERROR: Failed to build gem native extension.

    /Users/andriytyurnikov/.rbenv/versions/1.9.3-p194/bin/ruby extconf.rb

creating Makefile
CFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -Os -pipe -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow -Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion -Wshorten-64-to-32 -Wglobal-constructors -pedantic' /usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -dead_strip -framework CoreServices -o '/Users/andriytyurnikov/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rb-fsevent-0.4.3.1/bin/fsevent_watch' fsevent/fsevent_watch.c
fsevent/fsevent_watch.c:1:10: fatal error: 'stdio.h' file not found

include <stdio.h>

     ^

1 error generated.
extconf.rb:59:in `

': Compilation of fsevent_watch failed (see README) (RuntimeError)

Gem files will remain installed in /Users/andriytyurnikov/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rb-fsevent-0.4.3.1 for inspection.
Results logged to /Users/andriytyurnikov/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rb-fsevent-0.4.3.1/ext/gem_make.out

PowerPC Support on Mac OS 10.5.8

Hello,

With reference to: guard/guard#206 (comment)

I'm running rb-fsevent on a PowerPC and Mac OS 10.5.8. The CPU does not seem to be supported. If you have any suggestions on how I can get it to work or some workaround tools I could use I'd be very grateful.

If you need help compiling code etc, let me know.

Thanks in advance.

Jruby shutdown Error

When terming the server rb-fsevent fires this backtrace on Jruby-1.7.19. This is caused by a Process.kill on a pid that no longer exists, this issue could be native jruby. This occurs when terming or restarting a process, which calls stop.

I have a patch. Will submit it for your review if you guys would like.

    E, [2015-09-01T10:02:39.921000 #57325] ERROR -- : run() in thread failed: No such process - No such process:\n org/jruby/RubyProcess.java:979:in kill org/jruby/RubyProcess.java:889:in `kill'
    /Users/mrodrigues/.rvm/gems/jruby-1.7.19@jms/gems/rb-fsevent-0.9.5/lib/rb-fsevent/fsevent.rb:55:in `stop'
    /Users/mrodrigues/.rvm/gems/jruby-1.7.19@jms/gems/rb-fsevent-0.9.5/lib/rb-fsevent/fsevent.rb:50:in `run'
    /Users/mrodrigues/.rvm/gems/jruby-1.7.19@jms/gems/listen-3.0.3/lib/listen/adapter/darwin.rb:41:in `_run'
    /Users/mrodrigues/.rvm/gems/jruby-1.7.19@jms/gems/listen-3.0.3/lib/listen/adapter/base.rb:78:in `start'
    org/jruby/RubyProc.java:271:in `call'
    /Users/mrodrigues/.rvm/gems/jruby-1.7.19@jms/gems/listen-3.0.3/lib/listen/internals/thread_pool.rb:6:in `add'\n\ncalled from:\n /Users/mrodrigues/.rvm/gems    /jruby-1.7.19@jms/gems/listen-3.0.3/lib/listen/backend.rb:26:in `start'    

Install failing with 'no include path in which to search for stdio.h'

Using RVM and 1.9.2:

$ gem install rb-fsevent
Building native extensions.  This could take a while...
ERROR:  Error installing rb-fsevent:
    ERROR: Failed to build gem native extension.

        /Users/cdmwebs/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
creating Makefile
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -mdynamic-no-pic -std=gnu99 -Os -pipe -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow -Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion -Wshorten-64-to-32 -Wglobal-constructors -pedantic' /usr/bin/gcc -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -mdynamic-no-pic -std=gnu99 -dead_strip -framework CoreServices -o '/Users/cdmwebs/.rvm/gems/ruby-1.9.2-p180/gems/rb-fsevent-0.4.0/bin/fsevent_watch' fsevent/fsevent_watch.c
fsevent/fsevent_watch.c:1:19: error: no include path in which to search for stdio.h
fsevent/fsevent_watch.c:2:20: error: no include path in which to search for stdlib.h
fsevent/fsevent_watch.c:3:20: error: no include path in which to search for unistd.h
fsevent/fsevent_watch.c:5:39: error: no include path in which to search for CoreServices/CoreServices.h
fsevent/fsevent_watch.c:10: error: expected specifier-qualifier-list before ‘FSEventStreamEventId’
fsevent/fsevent_watch.c:15: error: ‘UInt64’ undeclared here (not in a function)
fsevent/fsevent_watch.c:15: warning: excess elements in struct initializer
fsevent/fsevent_watch.c:15: warning: (near initialization for ‘config’)
fsevent/fsevent_watch.c:15: error: expected ‘}’ before ‘kFSEventStreamEventIdSinceNow’
fsevent/fsevent_watch.c:24: error: expected ‘)’ before ‘streamRef’
fsevent/fsevent_watch.c: In function ‘append_path’:
fsevent/fsevent_watch.c:42: error: ‘PATH_MAX’ undeclared (first use in this function)
fsevent/fsevent_watch.c:42: error: (Each undeclared identifier is reported only once
fsevent/fsevent_watch.c:42: error: for each function it appears in.)
fsevent/fsevent_watch.c:44: warning: implicit declaration of function ‘realpath’
fsevent/fsevent_watch.c:44: error: ‘NULL’ undeclared (first use in this function)
fsevent/fsevent_watch.c:53: error: ‘size_t’ undeclared (first use in this function)
fsevent/fsevent_watch.c:53: error: expected ‘;’ before ‘len’
fsevent/fsevent_watch.c:54: warning: implicit declaration of function ‘getcwd’
fsevent/fsevent_watch.c:58: error: ‘len’ undeclared (first use in this function)
fsevent/fsevent_watch.c:58: warning: implicit declaration of function ‘strlen’
fsevent/fsevent_watch.c:58: warning: incompatible implicit declaration of built-in function ‘strlen’
fsevent/fsevent_watch.c:60: warning: implicit declaration of function ‘strlcpy’
fsevent/fsevent_watch.c:75: error: ‘CFStringRef’ undeclared (first use in this function)
fsevent/fsevent_watch.c:75: error: expected ‘;’ before ‘pathRef’
fsevent/fsevent_watch.c:78: warning: implicit declaration of function ‘CFArrayAppendValue’
fsevent/fsevent_watch.c:78: error: ‘struct ’ has no member named ‘paths’
fsevent/fsevent_watch.c:78: error: ‘pathRef’ undeclared (first use in this function)
fsevent/fsevent_watch.c:79: warning: implicit declaration of function ‘CFRelease’
fsevent/fsevent_watch.c: In function ‘parse_cli_settings’:
fsevent/fsevent_watch.c:85: error: ‘struct ’ has no member named ‘paths’
fsevent/fsevent_watch.c:85: warning: implicit declaration of function ‘CFArrayCreateMutable’
fsevent/fsevent_watch.c:85: error: ‘NULL’ undeclared (first use in this function)
fsevent/fsevent_watch.c:86: error: ‘CFIndex’ undeclared (first use in this function)
fsevent/fsevent_watch.c:86: error: expected ‘)’ before numeric constant
fsevent/fsevent_watch.c:90: warning: implicit declaration of function ‘strcmp’
fsevent/fsevent_watch.c:91: error: ‘struct ’ has no member named ‘sinceWhen’
fsevent/fsevent_watch.c:91: warning: implicit declaration of function ‘strtoull’
fsevent/fsevent_watch.c:93: error: ‘struct ’ has no member named ‘latency’
fsevent/fsevent_watch.c:93: warning: implicit declaration of function ‘strtod’
fsevent/fsevent_watch.c:95: error: ‘struct ’ has no member named ‘flags’
fsevent/fsevent_watch.c:95: error: ‘kFSEventStreamCreateFlagNoDefer’ undeclared (first use in this function)
fsevent/fsevent_watch.c:97: error: ‘struct ’ has no member named ‘flags’
fsevent/fsevent_watch.c:97: error: ‘kFSEventStreamCreateFlagWatchRoot’ undeclared (first use in this function)
fsevent/fsevent_watch.c:102: warning: implicit declaration of function ‘fprintf’
fsevent/fsevent_watch.c:102: warning: incompatible implicit declaration of built-in function ‘fprintf’
fsevent/fsevent_watch.c:102: error: ‘stderr’ undeclared (first use in this function)
fsevent/fsevent_watch.c:109: warning: implicit declaration of function ‘CFArrayGetCount’
fsevent/fsevent_watch.c:109: error: ‘struct ’ has no member named ‘paths’
fsevent/fsevent_watch.c: At top level:
fsevent/fsevent_watch.c:135: error: expected ‘)’ before ‘streamRef’
fsevent/fsevent_watch.c: In function ‘main’:
fsevent/fsevent_watch.c:172: error: ‘FSEventStreamContext’ undeclared (first use in this function)
fsevent/fsevent_watch.c:172: error: expected ‘;’ before ‘context’
fsevent/fsevent_watch.c:173: error: ‘FSEventStreamRef’ undeclared (first use in this function)
fsevent/fsevent_watch.c:173: error: expected ‘;’ before ‘stream’
fsevent/fsevent_watch.c:174: error: ‘stream’ undeclared (first use in this function)
fsevent/fsevent_watch.c:174: warning: implicit declaration of function ‘FSEventStreamCreate’
fsevent/fsevent_watch.c:174: error: ‘kCFAllocatorDefault’ undeclared (first use in this function)
fsevent/fsevent_watch.c:175: error: ‘FSEventStreamCallback’ undeclared (first use in this function)
fsevent/fsevent_watch.c:175: error: ‘callback’ undeclared (first use in this function)
fsevent/fsevent_watch.c:176: error: ‘context’ undeclared (first use in this function)
fsevent/fsevent_watch.c:177: error: ‘struct ’ has no member named ‘paths’
fsevent/fsevent_watch.c:178: error: ‘struct ’ has no member named ‘sinceWhen’
fsevent/fsevent_watch.c:179: error: ‘struct ’ has no member named ‘latency’
fsevent/fsevent_watch.c:180: error: ‘struct ’ has no member named ‘flags’
fsevent/fsevent_watch.c:188: warning: implicit declaration of function ‘FSEventStreamScheduleWithRunLoop’
fsevent/fsevent_watch.c:189: warning: implicit declaration of function ‘CFRunLoopGetCurrent’
fsevent/fsevent_watch.c:190: error: ‘kCFRunLoopDefaultMode’ undeclared (first use in this function)
fsevent/fsevent_watch.c:191: warning: implicit declaration of function ‘FSEventStreamStart’
fsevent/fsevent_watch.c:192: warning: implicit declaration of function ‘CFRunLoopRun’
fsevent/fsevent_watch.c:193: warning: implicit declaration of function ‘FSEventStreamFlushSync’
fsevent/fsevent_watch.c:194: warning: implicit declaration of function ‘FSEventStreamStop’
extconf.rb:48:in `': Compilation of fsevent_watch failed (see README) (RuntimeError)


Gem files will remain installed in /Users/cdmwebs/.rvm/gems/ruby-1.9.2-p180/gems/rb-fsevent-0.4.0 for inspection.
Results logged to /Users/cdmwebs/.rvm/gems/ruby-1.9.2-p180/gems/rb-fsevent-0.4.0/ext/gem_make.out

Not sure what to look for, really. Xcode is installed, etc. Thanks for any guidance.

Yosemite OSX 10.10 Events Not Firing

I have a fresh install of OSX 10.10 that will not fire events when a file is changed. Using ruby 2.1.2 and rb-fsevent-0.9.4, I created a test.rb file using the single path test. I then ran the ruby, but could not get an event to fire after changing files.

release 0.10.0

Ping @thibaudgg - enough changes have been made in master to make a release and bump the minor version number (rather than patch).

I'm slightly worried about the change to communications format between subprocess and ruby, but I'm a natural worrier and it seems to work pretty damn well locally. It fixes several bugs related to some file names breaking the watcher if they contain colons and newlines. From now on the communication format, rather than relying on delimiters, specifies quite explicitly how many characters are in each message.

An as-of-yet undocumented change is that the callback now accepts multiple parameters... The first still containing just a list of paths, with the second containing very detailed metadata on each individual change in the list. For example, if you enable file events, the metadata will now tell you whether the path is a directory, file, symbolic link, or hard link without you having to poke at the filesystem to get that info. Also, it will specify if the change is just metadata (permissions, etc) and can be safely ignored by Listen.

...It's undocumented because I'm not sure we honestly give a fuck right now when lisiten-fsevents will provide the same info without any backwards compatibility parameter, and will also allow you to ignore events originating from the current process (which will drop cpu/power requirements of Listen on MacOS significantly). It will also be able to watch the directory itself by file handle (so if you start watching /foo/bar and it's renamed to /foo/baz, it will continue to work).

The binary in master was built against the 10.8 SDK thanks to xcodelegacy making it easier to build against older SDKs using a current xcode.

I'm leaving it to you to do a release or not. I'm unsure whether it's worth waiting for a post install message. There's a lot that's fixed in master and will potentially make lives easier. At this point, I'm leaning towards just doing a release.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.