listen: Problems on Windows
- Polling doesn’t auto start on windows when WDM is not present
- WDM v0.1.0 does not work with guard 2.0.x
Notes:
- polling can be forced via by using the
--force-pollingoption under windows by conditionally sniffing the target os viaRbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/iand the guard daemon starts normally. - polling is not a great way of watching changes as it can take up to 5 minutes for it to see changes and I find myself manually triggering change events.
Re: 1 Below is a stack trace when WDM is not included in Gemfile
$ bundle exec guard --debug --guardfile "c:/path/to/Guardfile"
11:39:44 - INFO - Using Guardfile at c:/path/to/Guardfile.
11:39:46 - DEBUG - Command execution: emacsclient --eval '1' 2> NUL || echo 'N/A'
11:39:46 - INFO - Guard is using TerminalTitle to send notifications.
11:39:46 - DEBUG - Command execution: hash stty
11:39:46 - DEBUG - Guard starts all plugins
11:39:46 - DEBUG - Hook :start_begin executed for Guard::CoffeeScript
11:39:46 - DEBUG - Hook :start_end executed for Guard::CoffeeScript
11:39:46 - DEBUG - Hook :start_begin executed for Guard::Sass
11:39:46 - DEBUG - Hook :start_end executed for Guard::Sass
11:39:46 - DEBUG - Hook :start_begin executed for Guard::Sass
11:39:46 - DEBUG - Hook :start_end executed for Guard::Sass
11:39:46 - INFO - Guard is now watching at 'c:/path/to/project'
Please add the following to your Gemfile to avoid polling for changes:
require 'rbconfig'
gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i
c:/path/to/project/vendor/ruby/1.9.1/gems/listen-2.1.0/lib/listen/adapter.rb:37:in `_warn_polling_fallback': undefined method `gsub' for nil:NilClass (oMethodError)
from c:/path/to/project/vendor/ruby/1.9.1/gems/listen-2.1.0/lib/listen/adapter.rb:24:in `_select'
from c:/path/to/project/vendor/ruby/1.9.1/gems/listen-2.1.0/lib/listen/adapter.rb:14:in `new'
from c:/path/to/project/vendor/ruby/1.9.1/gems/listen-2.1.0/lib/listen/listener.rb:118:in `_init_actors'
from c:/path/to/project/vendor/ruby/1.9.1/gems/listen-2.1.0/lib/listen/listener.rb:37:in `start'
from c:/path/to/project/vendor/ruby/1.9.1/gems/guard-2.0.5/lib/guard/commander.rb:30:in `block in start'
from c:/path/to/project/vendor/ruby/1.9.1/gems/guard-2.0.5/lib/guard/commander.rb:108:in `block in within_preserved_state'
from <internal:prelude>:10:in `synchronize'
from c:/path/to/project/vendor/ruby/1.9.1/gems/guard-2.0.5/lib/guard/commander.rb:105:in `within_preserved_state'
from c:/path/to/project/vendor/ruby/1.9.1/gems/guard-2.0.5/lib/guard/commander.rb:26:in `start'
from c:/path/to/project/vendor/ruby/1.9.1/gems/guard-2.0.5/lib/guard/cli.rb:96:in `start'
from c:/path/to/project/vendor/ruby/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
from c:/path/to/project/vendor/ruby/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
from c:/path/to/project/vendor/ruby/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
from c:/path/to/project/vendor/ruby/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:439:in`start'
from c:/path/to/project/vendor/ruby/1.9.1/gems/guard-2.0.5/bin/guard:6:in `<top (required)>'
from c:/path/to/project/vendor/ruby/1.9.1/bin/guard:23:in `load'
from c:/path/to/project/vendor/ruby/1.9.1/bin/guard:23:in `<main>'
Re: 2 When wdm is included in the bundle the daemon silently exits:
AzT3k@AZT3K-E /C/path/to/project (master)
$ bundle exec guard --debug --guardfile "c:/path/to/Guardfile"
11:52:27 - INFO - Using Guardfile at c:/path/to/Guardfile.
11:52:28 - DEBUG - Command execution: emacsclient --eval '1' 2> NUL || echo 'N/A'
11:52:28 - INFO - Guard is using TerminalTitle to send notifications.
11:52:28 - DEBUG - Command execution: hash stty
11:52:28 - DEBUG - Guard starts all plugins
11:52:28 - DEBUG - Hook :start_begin executed for Guard::CoffeeScript
11:52:28 - DEBUG - Hook :start_end executed for Guard::CoffeeScript
11:52:28 - DEBUG - Hook :start_begin executed for Guard::Sass
11:52:28 - DEBUG - Hook :start_end executed for Guard::Sass
11:52:28 - DEBUG - Hook :start_begin executed for Guard::Sass
11:52:28 - DEBUG - Hook :start_end executed for Guard::Sass
11:52:28 - INFO - Guard is now watching at 'c:/path/to/project'
11:52:28 - DEBUG - Start interactor
AzT3k@AZT3K-E /C/path/to/project (master)
$
The contents of the Gemfile and Guardfile are available here: https://github.com/guard/guard/issues/492
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Reactions: 1
- Comments: 82 (35 by maintainers)
@e2 - I believe that I’m experiencing the same or similar issue so any help would be appreciated.
I’m running Drupal and the Omega theme which uses ruby and sass/compass to process the css files and update the browser.
The issues are when running on a windows development stack
Win 7 64bit ruby 1.9.3p545 (2014-02-24) [i386-mingw32]
The gemfile is
source ‘https://rubygems.org’
group :development do
Sass, Compass and extensions.
gem ‘sass’ # Sass. gem ‘sass-globbing’ # Import Sass files based on globbing pattern. gem ‘compass’ # Framework built on Sass. gem ‘compass-validator’ # So you can
compass validate. gem ‘compass-normalize’ # Compass version of normalize.css. gem ‘compass-rgbapng’ # Turns rgba() into .png’s for backwards compatibility. gem ‘susy’ # Susy grid framework. gem ‘singularitygs’ # Alternative to the Susy grid framework. gem ‘toolkit’ # Compass utility from the fabulous Snugug. gem ‘breakpoint’ # Manages CSS media queries. gem ‘oily_png’ # Faster Compass sprite generation. gem ‘css_parser’ # Helpscompass statsoutput statistics.Guard
gem ‘guard’ # Guard event handler. gem ‘guard-compass’ # Compile on sass/scss change. gem ‘guard-shell’ # Run shell commands. gem ‘guard-livereload’ # Browser reload. gem ‘yajl-ruby’ # Faster JSON with LiveReload in the browser.
Dependency to prevent polling. Setup for multiple OS environments.
Optionally remove the lines not specific to your OS.
https://github.com/guard/guard#efficient-filesystem-handling
gem ‘rb-inotify’, ‘~> 0.9’, :require => false # Linux gem ‘rb-fsevent’, :require => false # Mac OSX gem ‘rb-fchange’, :require => false # Windows
require ‘rbconfig’ if RbConfig::CONFIG[‘target_os’] =~ /mswin|mingw|cygwin/i gem ‘wdm’, ‘>= 0.1.0’ end end
The gemfile.lock is
GEM remote: https://rubygems.org/ specs: addressable (2.3.6) breakpoint (2.5.0) sass (~> 3.3) sassy-maps (< 1.0.0) celluloid (0.16.0) timers (~> 4.0.0) chunky_png (1.3.1) coderay (1.1.0) compass (1.0.1) chunky_png (~> 1.2) compass-core (~> 1.0.1) compass-import-once (~> 1.0.5) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) sass (>= 3.3.13, < 3.5) compass-core (1.0.1) multi_json (~> 1.0) sass (>= 3.3.0, < 3.5) compass-import-once (1.0.5) sass (>= 3.2, < 3.5) compass-normalize (1.5) compass (>= 0.12.0) compass-rgbapng (0.2.1) chunky_png (>= 0.8.0) compass (>= 0.10.0) compass-validator (3.0.1) css_parser (1.3.5) addressable em-websocket (0.5.1) eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) eventmachine (1.0.3-x86-mingw32) ffi (1.9.3-x86-mingw32) formatador (0.2.5) guard (2.6.1) formatador (>= 0.2.4) listen (~> 2.7) lumberjack (~> 1.0) pry (>= 0.9.12) thor (>= 0.18.1) guard-compass (1.1.0) compass (>= 0.10.5) guard (~> 2.0) guard-livereload (2.3.0) em-websocket (~> 0.5) guard (~> 2.0) multi_json (~> 1.8) guard-shell (0.6.1) guard (>= 1.1.0) hitimes (1.2.2) http_parser.rb (0.6.0) listen (2.7.9) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) lumberjack (1.0.9) method_source (0.8.2) multi_json (1.10.1) oily_png (1.1.1) chunky_png (~> 1.3.0) pry (0.10.1-x86-mingw32) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) win32console (~> 1.3) rb-fchange (0.0.6) ffi rb-fsevent (0.9.4) rb-inotify (0.9.5) ffi (>= 0.5.0) sass (3.4.3) sass-globbing (1.1.1) sass (>= 3.1) sassy-maps (0.4.0) sass (~> 3.3) singularitygs (1.4.0) breakpoint (~> 2.4) sass (~> 3.3) slop (3.6.0) susy (2.1.3) sass (>= 3.3.0, < 3.5) thor (0.19.1) timers (4.0.1) hitimes toolkit (2.6.0) sass (~> 3.3) wdm (0.1.0) win32console (1.3.2-x86-mingw32) yajl-ruby (1.2.1)
PLATFORMS x86-mingw32
DEPENDENCIES breakpoint compass compass-normalize compass-rgbapng compass-validator css_parser guard guard-compass guard-livereload guard-shell oily_png rb-fchange rb-fsevent rb-inotify (~> 0.9) sass sass-globbing singularitygs susy toolkit wdm (>= 0.1.0) yajl-ruby
If I call ‘bundle exec guard --force-polling’
Changes are detected and everything works however it runs the CPU’s virtual core are 100% even though there is less than 100 files for it to check.
If I call ‘bundle exec guard’ it just silently exits after it says it’s monitoring the files.
If I set the environment variable LISTEN_GEM_DEBUGGING=1 then it returns
16:10:21 - INFO - Guard::Compass is waiting to compile your stylesheets. 16:10:21 - INFO - Guard is now watching at ‘C:/drupal_project’ 16:10:21 - INFO - LiveReload is waiting for a browser to connect. I, [2014-09-12T16:10:21.858138 #8992] INFO – : Record.build took 0.07100415229797363 seconds
With LISTEN_GEM_DEBUGGING=2 I get
I, [2014-09-12T16:19:39.227017 #6116] INFO – : Celluloid loglevel set to: 0
16:19:49 - INFO - Guard::Compass is waiting to compile your stylesheets. 16:19:49 - INFO - Guard is now watching at ‘C:/drupal_project’ 16:19:49 - INFO - LiveReload is waiting for a browser to connect. D, [2014-09-12T16:19:49.155585 #6116] DEBUG – : Adapter: considering TCP … D, [2014-09-12T16:19:49.155585 #6116] DEBUG – : Adapter: considering polling … D, [2014-09-12T16:19:49.156585 #6116] DEBUG – : Adapter: considering optimized backend… I, [2014-09-12T16:19:49.244590 #6116] INFO – : Record.build took 0.07000398635864258 seconds D, [2014-09-12T16:19:49.246590 #6116] DEBUG – : wdm - starting…
Very occasionally it does work without force polling but it’s very rare but I can’t find any pattern to replicate when it works. When it does work the CPU usage is neglible.
I’m new to Ruby so if you have any ideas or advice (ideally other than don’t use windows 😃) it would be gratefully received.
I’ve used
gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin/iinstead ofgem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i(runningbundle exec guardin standard windows command line) and it doesn’t silently exits any more…