Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

poll vs inotify vs fsevent #340

Closed
rking opened this Issue · 6 comments

2 participants

@rking

So, there's an issue with cross-platform development.

Guard is happiest when it has something other than polling, of course, so the naïve Linuxer adds this to his Gemfile:

gem 'rb-inotify'

Then he makes his OS X coworker so sad when that won't install. The OS X
coworker then does:

case RUBY_PLATFORM
when /linux/i
  gem 'rb-inotify'
when /darwin/i
  gem 'rb-fsevent'
end

And it sort of works, but then he ends up comitting a diff into Gemfile.lock
removing rb-inotify and adding rb-fsevent. Then the two play
tug-of-Gemfile.lock until one or the other ragequits the project.

I talked to @injekt, and he said it would be nice if Gemfile.locks had
platform-specific blocks, but there are issues with that (e.g. you can't
extend the grammar of Gemfile.lock without causing existing Bundlers to blow
up).

I kicked around a few dumb ideas, but (thanks to @rf-) I think we've got a
non-dumb idea to propose:

Step 1: Create a generic polling gem that does the job of guards poll stuff plus a conditional, optional C piece for either libnotify or libfsevent.
Step 2: Depend on it, unconditionally.
Step 3: Figure out what the user experience should be if they're on Linux without libnotify, etc.

BTW my proposed name for this thing is either libfisneovteinfty or
libifnsoetviefnyt. Just (mostly) kidding. :neckbeard:

@thibaudgg
Owner

Hi @rking,

We already have that discussion for the Listen gem: https://github.com/guard/listen/issues/search?q=dependencies

In your case the solution would be to required all dependencies without the RUBY_PLATFORM case:

  gem 'rb-inotify'
  gem 'rb-fsevent'

It should work everywhere. (Listen was using this approach first).

@thibaudgg thibaudgg closed this
@rking

Oh man, that's so simple.

I don't think I can climb out of the idiot hole on this one, but for what it's
worth, these don't say the gems work fine on other OS's:

(And, interestingly, the wdm gem does not behave in this mild-mannered manner).

Thanks for the solution, though!

@rking

(rb-fchange actually doesn't complain when you gem install it, but it does complain when you require it — but it's not mentioned on the guard README.md)

@thibaudgg
Owner

Ok, just add :require => false on your Gemfile. Listen will automatically require the good one.

  gem 'rb-inotify', :require => false
  gem 'rb-fsevent', :require => false
  gem 'rb-fchange', :require => false
@rking

Looks good to me. Could this be added to the docs (or perhaps be made part of guard/listen)?

@thibaudgg
Owner

Yeah adding that in the Guard README is a good idea, can you submit a pull request please? Thanks.

@rking rking referenced this issue from a commit in rking/guard
@rking rking Update for Gemfile solution. Addresses #340.
Note that I dropped the mention of the `wdm` gem. I don't see that it
does something better than `rb-fchange`, and it also fails loudly upon
attempted install onto Linux.
b36c6d2
@rking rking referenced this issue in Maher4Ever/wdm
Closed

Install + Run on Non-Windows #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.