Skip to content

GEdit / INotify / Linux fix #79

Closed
Gazer opened this Issue Jun 9, 2011 · 10 comments

5 participants

@Gazer
Gazer commented Jun 9, 2011

Gedit saves files in an uncommon way. They write a temporary files and then move to overwrite the original filename.

Guard on linux right now are only watching for modify and create events, so, modifying a file from gedit is never detected because the final event is a IN_MOVE_TO. So, adding :moved_to in the worker.watch of listener/linux.rb:47 fix this problem.

I dont know if this has a drawback, but if not, it would be nice to have in the next release :)

Thank you!

@rymai
Guard member
rymai commented Jun 9, 2011

I don't think this has drawback, but I'm not using Linux so I can't really tell. Anyway, feel free to do a pull-request if you think it's appropriate! :)

Thanks!

@yannlugrin
Guard member

Event detected by guard on Linux is probably not quite enough If you send a pull request, we probably can merge it, but test your patch in real world (with GEdit) before please.

@Gazer
Gazer commented Jun 10, 2011

Thanks for the quick reply. Rigth now the fix as expressed in the first post is working with gedit.

I'll be forking the project tomorrow and testing this fix severals editors (at least the popular ones : vim, emacs, gedit, somee KDE's editor) to be sure that don't break, and send a pull request if all is goin smooth.

@peplin
peplin commented Jun 10, 2011

FWIW, vim saves files in the same way (write to temporary, copy on top of old) if set backup is enabled. I just noticed this because my Dropbox revision history had a series of delete+add instead of modify.

@Gazer
Gazer commented Jun 10, 2011

Ok, first problem :). If we support moved_to, we break the spec "not catches a moved file" from 'it_should_behave_like "a listener that reacts to #on_change"'.

I'll try using CLOSE_WRITE and see if behave as expected (at least with GEdit works file, and File.touch is now recognized)

@yannlugrin yannlugrin added a commit that closed this issue Jun 17, 2011
@Gazer Gazer Improve INotify support on linux (fixes #79 #82)
Improve usage with several text editors that writes to temporal
files and then move over the original filename instead of write
files directly. Tested with GEdit, Nano, vim (with 'set backup'
and 'set nobackup') and emacs.
d51b457
@msolovyov

I'm still having this issue with gedit.

Specs run when I touch them or use nano to edit.

But when using gedit guard doesn't pick up the change.

Using the guard git repo in my gemfile, so latest source.

@yannlugrin
Guard member

Have you tried to run guard with bundle exec ?

bundle exec guard

@msolovyov

When I run it with that, I think spork takes issue with it.

```Guard::RSpec is running, with RSpec 2!
Running all specs
RuntimeError: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
method_missing at /home/michael/.rvm/rubies/jruby-1.6.2/lib/ruby/1.8/drb/drb.rb:1134

@yannlugrin
Guard member

To install guard from source, you can follow this instruction :

git clone git://github.com/guard/guard.git
cd guard
bundle install
gedit lib/guard/version.rb # replace "0.4.2" by "0.4.2.1"
rake install

This install a version 0.4.2.1 on your system and you can run guard without bundler now.

@msolovyov

Followed instructions, now I get the following error when I run guard:
To note, I'm using guard with spork.

$ guard -g rspec
The signal QUIT is in use by the JVM and will not work correctly on this platform
Guard is now watching at '/home/michael/dev/git4/nfproto'
Guard::RSpec is running, with RSpec 2!
Running all specs
RuntimeError: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
  method_missing at /home/michael/.rvm/rubies/jruby-1.6.2/lib/ruby/1.8/drb/drb.rb:1134
             run at /home/michael/.rvm/gems/jruby-1.6.2@railspre/gems/rspec-core-2.6.4/lib/rspec/core/drb_command_line.rb:19
    run_over_drb at /home/michael/.rvm/gems/jruby-1.6.2@railspre/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:76
             run at /home/michael/.rvm/gems/jruby-1.6.2@railspre/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:63
         autorun at /home/michael/.rvm/gems/jruby-1.6.2@railspre/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11
            call at org/jruby/RubyProc.java:268
            call at org/jruby/RubyProc.java:232

This might be a spork+jruby issue though, but it used to work.

Edit: Looks like it was just an error in one of my specs. Looks like it works now. Thanks.

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.