Closed wulftone closed 10 years ago
Have you read https://github.com/guard/listen/issues/154? You have maybe the same issue.
Yeah I have less than 4k files--and half of them are in the .git directory anyway.. that guy had almost 50k files.
2000 files can't be too many, that'd be silly!
EDIT: I doubt it's even looking at more than a couple hundred, also, since a lot of garbage is put into ./tmp
by the asset pipeline.
Interestingly, polling seems to eat up 25-30% of each of my four logical cores. Not so good for the battery. : \
From the backtrace, it seems that the modification of app/services/yc/consequence_services.rb
is detected as an addition and not a modification (and guard-rspec reacts only to modifications since 4.0.0)...
app/services/yc/consequence_services.rb
in Guard's interactor and paste the output here.Celluloid::Actor[:listen_adapter]
in Guard's interactor and paste the output here.Thanks in advance!
[1] guard(main)> Celluloid::Actor[:listen_adapter] => #<Celluloid::ActorProxy(Listen::Adapter::Linux:0x1784988) @listener=#<Listen::Listener:0x0000000599c8c0 @options={:debug=>false, :latency=>nil, :force_polling=>false, :polling_fallback_message=>nil}, @directories=[#<Pathname:/home/trevor/fruhla/homefront>], @changes=[], @block=#<Proc:0x0000000599caa0@/home/trevor/.rvm/gems/ruby-2.0.0-p247/gems/guard-2.2.2/lib/guard/setuper.rb:173 (lambda)>, @paused=false, @thread=#<Thread:0x00000002d98210 sleep>>>
Oops, sorry I forgot a word for 3.!!
Correction: Please run change app/services/yc/consequence_services.rb
in Guard's interactor and paste the output here.
Btw, thanks for the useful infos!
Can you try to run the Listen master specs suite please, there's maybe a particular issue with Debian.
I can confirm the problem mentioned by @wulftone. Most probably it is connected with Sublime 3. When I started my application and saved one of my spec in Sublime 3 nothing happened, but after saving the same file in vim (:w) change was discovered guard started correlated tests.
All my tests were executed on Kubuntu 13.10.
I run listen spec
(from master) and there everything seems to be ok (166 examples, 0 failures
)
[2] guard(main)> Celluloid::Actor[:listen_adapter]
=> #<Celluloid::ActorProxy(Listen::Adapter::Linux:0x3fa0382b09f4) @listener=#<Listen::Listener:0x007f40711a4b28 @options={:debug=>false, :latency=>nil, :force_polling=>false, :polling_fallback_message=>nil}, @directories=[#<Pathname:/home/marek/git/rails/air>], @changes=[], @block=#<Proc:0x007f40711a4cb8@/home/marek/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/guard-2.2.2/lib/guard/setuper.rb:173 (lambda)>, @paused=false, @thread=#<Thread:0x007f4070b2efc8 sleep>>>
Ok interesting, because I use Sublime Text 3 on OS X and it works fine. @wulftone can you confirm that it works with vim
for you?
We have a wiki page about inotify events with different editors: https://github.com/guard/guard/wiki/Analysis-of-inotify-events-for-different-editors Maybe it changes on SublimeText 3!
@tinamou Please run change path/to/a/file_spec.rb
in Guard's interactor and paste the output here. It should work as expected and this would confirm this issue is related to the way Sublime Text 3 saves files on Linux.
@rymai I'm not sure if I done it correctly:
12:20:18 - DEBUG - Command execution: emacsclient --eval '1' 2> /dev/null || echo 'N/A'
12:20:18 - INFO - Guard is using Libnotify to send notifications.
12:20:18 - INFO - Guard is using TerminalTitle to send notifications.
12:20:18 - DEBUG - Command execution: hash stty
12:20:18 - DEBUG - Guard starts all plugins
12:20:18 - DEBUG - Hook :start_begin executed for Guard::RSpec
12:20:18 - INFO - Guard::RSpec is running
12:20:18 - DEBUG - Hook :start_end executed for Guard::RSpec
12:20:18 - DEBUG - Hook :start_begin executed for Guard::Spork
12:20:18 - DEBUG - Command execution: ps aux | grep -v guard | awk '/spork/&&!/awk/{print $2;}'
12:20:18 - DEBUG - Killing Spork servers with PID:
12:20:18 - INFO - Starting Spork for RSpec
12:20:18 - DEBUG - guard-spork command execution: ["exec", "spork", "-p", "8989"]
Using RSpec, Rails
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
12:20:22 - INFO - Spork server for RSpec successfully started
12:20:22 - DEBUG - Hook :start_end executed for Guard::Spork
12:20:22 - INFO - Guard is now watching at '/home/marek/git/rails/air'
12:20:22 - DEBUG - Start interactor
[1] guard(main)> change '/home/marek/git/rails/air/spec/models/appliance_spec.rb'
12:20:43 - DEBUG - Stop interactor
# Save using SublimeText 3
12:20:43 - DEBUG - Trying to run Guard::RSpec#run_on_additions with ["spec/models/appliance_spec.rb"]
12:20:43 - DEBUG - Trying to run Guard::RSpec#run_on_changes with ["spec/models/appliance_spec.rb"]
12:20:43 - DEBUG - Trying to run Guard::RSpec#run_on_change with ["spec/models/appliance_spec.rb"]
12:20:43 - DEBUG - Start interactor
12:20:50 - DEBUG - Stop interactor
12:20:50 - DEBUG - Start interactor
12:20:51 - DEBUG - Stop interactor
# Save using Vim
12:20:51 - DEBUG - Hook :run_on_modifications_begin executed for Guard::RSpec
12:20:51 - INFO - Running: spec/models/appliance_spec.rb
WARN: Unresolved specs during Gem::Specification.reset:
rb-inotify (>= 0.9)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
................
Finished in 0.57616 seconds
16 examples, 0 failures
Randomized with seed 29917
12:20:55 - DEBUG - Hook :run_on_modifications_end executed for Guard::RSpec
12:20:55 - DEBUG - Trying to run Guard::RSpec#run_on_additions with ["spec/models/appliance_spec.rb"]
12:20:55 - DEBUG - Trying to run Guard::RSpec#run_on_changes with ["spec/models/appliance_spec.rb"]
12:20:55 - DEBUG - Trying to run Guard::RSpec#run_on_change with ["spec/models/appliance_spec.rb"]
12:20:55 - DEBUG - Trying to run Guard::RSpec#run_on_removals with ["spec/models/appliance_spec.rb"]
12:20:55 - DEBUG - Trying to run Guard::RSpec#run_on_changes with ["spec/models/appliance_spec.rb"]
12:20:55 - DEBUG - Trying to run Guard::RSpec#run_on_deletion with ["spec/models/appliance_spec.rb"]
12:20:55 - DEBUG - Start interactor
What is more I'm not sure why unresolved spec warning are shown, in my Gemfile I have following deps:
marek@leeloo:~/git/rails/air (master *$=)$ cat Gemfile.lock | grep rb-inotify
rb-inotify (>= 0.9)
rb-inotify (0.9.2)
marek@leeloo:~/git/rails/air (master *$=)$ cat Gemfile.lock | grep rspec-expectations
rspec-expectations (~> 2.14.0)
rspec-expectations (2.14.3)
rspec-expectations (~> 2.14.0)
marek@leeloo:~/git/rails/air (master *$=)$ cat Gemfile.lock | grep rspec-mocks
rspec-mocks (~> 2.14.0)
rspec-mocks (2.14.4)
rspec-mocks (~> 2.14.0)
Ok, it definitely looks like a Sublime Text 3 / Linux issue then...
The strange thing is that change '/home/marek/git/rails/air/spec/models/appliance_spec.rb'
seems to do nothing!
@wulftone @tinamou could you analyze SublimeVideo 3 inotify events with inotifywatch as explained in the wiki: https://github.com/guard/guard/wiki/Analysis-of-inotify-events-for-different-editors
Thanks!
marek@leeloo:~/git/rails/air (master $=)$ inotifywatch spec/models/appliance_spec.rb
Establishing watches...
Finished establishing watches, now collecting statistics.
total attrib delete_self filename
3 1 1 spec/models/appliance_spec.rb
Ok, that's weird because attrib
event is listened: https://github.com/guard/listen/blob/master/lib/listen/adapter/linux.rb#L12
I tried minimalistic scenario from listen
manual:
marek@leeloo:~/tmp/listen$ bundle exec pry
[1] pry(main)> require 'listen'
=> true
[2] pry(main)> listener = Listen.to('/home/marek/git/rails/air') do |modified, added, removed|
[2] pry(main)* puts "modified absolute path: #{modified}"
[2] pry(main)* puts "added absolute path: #{added}"
[2] pry(main)* puts "removed absolute path: #{removed}"
[2] pry(main)* end
=> #<Listen::Listener:0x007f6c3574fa38
@block=#<Proc:0x007f6c3574fa88@(pry):2>,
@changes=[],
@directories=[#<Pathname:/home/marek/git/rails/air>],
@options=
{:debug=>false,
:latency=>nil,
:wait_for_delay=>0.1,
:force_polling=>false,
:polling_fallback_message=>nil}>
[3] pry(main)> listener.start
=> #<Thread:0x007f6c3517d3d0 run>
# Sublimetext 3 save
[4] pry(main)>
[5] pry(main)> modified absolute path: []
added absolute path: ["/home/marek/git/rails/air/spec/models/appliance_spec.rb"]
removed absolute path: []
[5] pry(main)>
[6] pry(main)>
[7] pry(main)>
# Vim save
[8] pry(main)> modified absolute path: ["/home/marek/git/rails/air/spec/models/appliance_spec.rb", "/home/marek/git/rails/air/spec/models/4913"]
added absolute path: ["/home/marek/git/rails/air/spec/models/appliance_spec.rb", "/home/marek/git/rails/air/spec/models/appliance_spec.rb~", "/home/marek/git/rails/air/spec/models/4913"]
removed absolute path: ["/home/marek/git/rails/air/spec/models/appliance_spec.rb~", "/home/marek/git/rails/air/spec/models/appliance_spec.rb", "/home/marek/git/rails/air/spec/models/4913"]
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
celluloid (0.15.2)
timers (~> 1.1.0)
coderay (1.0.9)
ffi (1.9.0)
listen (2.2.0)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
method_source (0.8.2)
pry (0.9.12.2)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rb-fsevent (0.9.3)
rb-inotify (0.9.2)
ffi (>= 0.5.0)
slop (3.4.6)
timers (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
listen (~> 2.0)
pry
It seems like listen
does not recognize file modifications. Are there any other tests I can perform to help solve this issue?
@tinamou could you give your vim
inotify events as well? You could also try to edit the events list in the Linux adapter to see if it changes anything for you https://github.com/guard/listen/blob/master/lib/listen/adapter/linux.rb#L12
We should also ignore .*~
files like /home/marek/git/rails/air/spec/models/appliance_spec.rb~
right?
inotify events for vim
:
Establishing watches...
Finished establishing watches, now collecting statistics.
total attrib move_self delete_self filename
4 1 1 1 spec/models/appliance_spec.rb
letter on I will try to play with https://github.com/guard/listen/blob/master/lib/listen/adapter/linux.rb#L12.
According to .*~
you are probably right. As far as I know this kind of files are created by vim
and e.g. kate
on kubuntu.
Ok great, let me know. Note: event flags are converted to changes here: https://github.com/guard/listen/blob/master/lib/listen/adapter/linux.rb#L74-L81
I added
puts "_worker_callback lambda event #{event.flags} #{_change(event.flags)}"
into https://github.com/guard/listen/blob/master/lib/listen/adapter/linux.rb#L54
and
puts "_notify_change(#{path}, #{options})"
into https://github.com/guard/listen/blob/master/lib/listen/adapter/base.rb#L35
Bellow you can find the results:
_worker_callback lambda event [:create] added
_notify_change(/home/marek/git/rails/air/spec/models/.subl4e.tmp, {:type=>"file", :change=>:added})
_worker_callback lambda event [:attrib] modified
_notify_change(/home/marek/git/rails/air/spec/models/.subl4e.tmp, {:type=>"file", :change=>:modified})
_worker_callback lambda event [:close_write, :close]
_notify_change(/home/marek/git/rails/air/spec/models/.subl4e.tmp, {:type=>"file", :change=>nil})
_worker_callback lambda event [:attrib] modified
_notify_change(/home/marek/git/rails/air/spec/models/.subl4e.tmp, {:type=>"file", :change=>:modified})
_worker_callback lambda event [:moved_from, :move] removed
_notify_change(/home/marek/git/rails/air/spec/models/.subl4e.tmp, {:type=>"file", :change=>:removed})
_worker_callback lambda event [:moved_to, :move] added
_notify_change(/home/marek/git/rails/air/spec/models/appliance_spec.rb, {:type=>"file", :change=>:added})
modified absolute path: []
added absolute path: ["/home/marek/git/rails/air/spec/models/appliance_spec.rb"]
removed absolute path: []
So it seems like attrib
event is not generated for appliance_spec.rb
file
It seems like rb-inotify
generates different events when listening file and directory. Following code:
require 'rb-inotify'
notifier = INotify::Notifier.new
notifier.watch('/home/marek/git/rails/air/spec/models/appliance_spec.rb', :attrib) do |event|
puts "#{event.flags} is now in #{event.absolute_name}!"
end
notifier.run
generates:
[:attrib] is now in /home/marek/git/rails/air/spec/models/appliance_spec.rb!
[:ignored] is now in /home/marek/git/rails/air/spec/models/appliance_spec.rb!
while saving file using Sublimetext3. But following code:
require 'rb-inotify'
EVENTS = [:recursive, :attrib, :create, :delete, :move, :close_write]
notifier = INotify::Notifier.new
notifier.watch('/home/marek/git/rails/air', *EVENTS) do |event|
puts "#{event.flags} is now in #{event.absolute_name}!"
end
notifier.run
generates:
[:create] is now in /home/marek/git/rails/air/spec/models/.subleb0.tmp!
[:attrib] is now in /home/marek/git/rails/air/spec/models/.subleb0.tmp!
[:close_write, :close] is now in /home/marek/git/rails/air/spec/models/.subleb0.tmp!
[:attrib] is now in /home/marek/git/rails/air/spec/models/.subleb0.tmp!
[:moved_from, :move] is now in /home/marek/git/rails/air/spec/models/.subleb0.tmp!
[:moved_to, :move] is now in /home/marek/git/rails/air/spec/models/appliance_spec.rb!
@nex3 any ideas about that? Thanks in advance!
@tinamou any news on that one? If you still got some issue with rb-inotify
please open an issue on it.
Dunno what changed, but it appears to be fixed now... I'm on Guard 2.2.4 and Listen 2.2.0.
@wulftone which version of guard-rspec
are you using? For me it works with listen
2.2.0 and guard
2.2.4 as far as I'm using guard-rspec
3.0.2 for 4.0.x it does not work. It is connected with https://github.com/guard/guard/issues/495#issuecomment-25981127 and https://github.com/nex3/rb-inotify/issues/31.
@thibaudgg I was unable to figure out what specific behavior issues @tinamou was reporting here.
@tinamou & @thibaudgg : I confirm downgrading guard-rspec to before 4.0.0 kind of fixed it for me. I'm using listen 2.3.1 and guard 2.2.4. And sublime text 3. I have no guard problems with sublime text 2.
If I make a change in a file, I see this: guard-rspec 4.0.0
23:46:03 - DEBUG - Trying to run Guard::RSpec#run_on_additions with ["spec/features/region_pages_spec.rb"]
23:46:03 - DEBUG - Trying to run Guard::RSpec#run_on_changes with ["spec/features/region_pages_spec.rb"]
23:46:03 - DEBUG - Trying to run Guard::RSpec#run_on_change with ["spec/features/region_pages_spec.rb"]
guard-rspec 3.1.0
23:47:12 - DEBUG - Trying to run Guard::RSpec#run_on_additions with ["spec/features/region_pages_spec.rb"]
23:47:12 - DEBUG - Hook :run_on_changes_begin executed for Guard::RSpec
23:47:13 - INFO - Running: spec/features/region_pages_spec.rb
I say "kind of" because, unfortunately, LiveReload/guard-livereload is not getting notified on changes with any gem version combination I tried.
00:00:35 - DEBUG - Trying to run Guard::LiveReload#run_on_additions with ["/assets/_custom_styles.sass"]
00:00:35 - DEBUG - Trying to run Guard::LiveReload#run_on_changes with ["/assets/_custom_styles.sass"]
00:00:35 - DEBUG - Trying to run Guard::LiveReload#run_on_change with ["/assets/_custom_styles.sass"]
guard-livereload and guard-rspec are now only use run_on_modifications
(https://github.com/guard/guard-livereload/blob/master/lib/guard/livereload.rb#L30, https://github.com/guard/guard-rspec/blob/master/lib/guard/rspec.rb#L32)
On your console I see only run_on_additions
and run_on_changes
it's so certainly an issue with file events. Could you try to change atomic save in SublimeText settings:
Wow, turning off atomic_save did it ("atomic_save": false
), run_on_modifications
gets executed. Also, guard-rspec 4.2 works fine.
Good find, thanks.
@wulftone and @tinamou same for you?
after turning off atomic_save
it started to work with guard-rspec (4.2.0)
:+1:
thanks!
For those who need some clarity, and in case those links die, in Sublime Text's settings (Preferences -> Settings - User), you need to add a line that says "atomic_save": false
. For example, here's part of my settings file:
{
"atomic_save": false, // this thing right here fixes the issue
"show_line_endings": true,
"sublimelinter_gutter_marks": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
}
I have the same issue no Ubuntu 13.10 -- it happens with Emacs. Are there any workaround for this?
Oh man, I have been trying to fix this for weeks now and setting 'atomic save' to false did it for me. Ubuntu 13.10 with Sublime Text 3 -- thanks so much for this!
At last, "atomic_save": false worked for me as well. I've been trying all day to get this working..
Linux Mint 16 Petra / Sublime Text 3
So I updated from guard 1.8.3 to 2.2.2, and it won't listen properly anymore. It works fine if I start guard with the
-p
switch, otherwise, it just sits there forever. There's some more info from other users here: https://github.com/guard/guard/issues/503Guardfile:
Gemfile:
Test run:
OS: Debian wheezy Ruby: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux] Rubygems: 2.0.3 Bundler: 1.3.5 Context: Large Ruby on Rails project
I hope that's enough to at least start... So it is watching, but not running rspec. It also does not reload the Guardfile when I save it:
Thanks for your help!