Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems on Windows #149

Closed
azt3k opened this issue Oct 13, 2013 · 82 comments
Closed

Problems on Windows #149

azt3k opened this issue Oct 13, 2013 · 82 comments

Comments

@azt3k
Copy link

azt3k commented Oct 13, 2013

  1. Polling doesn't auto start on windows when WDM is not present
  2. WDM v0.1.0 does not work with guard 2.0.x

Notes:

  • polling can be forced via by using the--force-polling option under windows by conditionally sniffing the target os via RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i and 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: guard/guard#492

@thibaudgg
Copy link
Member

Could you please checkout Listen master and try to run the spec suite with CI=true bundle exec rspec and paste the output here. Thanks!

@azt3k
Copy link
Author

azt3k commented Oct 14, 2013

AzT3k@AZT3K-E /C/_temp/listen (master)
$ bundle install --path vendor
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake (10.1.0)
Using bundler (1.3.5)
Installing timers (1.1.0)
Installing celluloid (0.15.2)
Installing coderay (1.0.9)
Installing multi_json (1.8.1)
Installing mime-types (1.25)
Installing rest-client (1.6.7)
Installing simplecov-html (0.7.1)
Installing simplecov (0.7.1)
Installing tins (0.12.0)
Installing term-ansicolor (1.2.2)
Installing thor (0.18.1)
Installing coveralls (0.7.0)
Installing diff-lcs (1.2.4)
Installing ffi (1.9.0)
Installing formatador (0.2.4)
Installing rb-fsevent (0.9.3)
Installing rb-inotify (0.9.2)
Using listen (2.1.0) from source at c:/Design/Projects/ABC/_temp/listen
Installing lumberjack (1.0.4)
Installing method_source (0.8.2)
Installing slop (3.4.6)
Installing win32console (1.3.2)
Installing pry (0.9.12.2)
Installing guard (2.0.5)
Installing rspec-core (2.14.5)
Installing rspec-expectations (2.14.3)
Installing rspec-mocks (2.14.3)
Installing rspec (2.14.1)
Installing guard-rspec (4.0.1)
Installing rspec-retry (0.2.1)
Installing wdm (0.1.0)
Installing yard (0.8.7.2)
Your bundle is complete!
It was installed into ./vendor

AzT3k@AZT3K-E /C/_temp/listen (master)
$ export CI=true && bundle exec rspec
←[32m[Coveralls] Set up the SimpleCov formatter.←[0m
←[32m[Coveralls] Using SimpleCov's default settings.←[0m
You must use ANSICON 1.31 or later (http://adoxa.3eeweb.com/ansicon/) to use colour on Windows
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Listen
  with one listen dir
    with change block raising

@thibaudgg
Copy link
Member

Ok same as before, if you launch just some specific specs:

  • export CI=true && bundle exec rspec spec/lib/listen/adapter_spec.rb
  • export CI=true && bundle exec rspec spec/lib/listen/adapter

@azt3k
Copy link
Author

azt3k commented Oct 14, 2013

$ export CI=true && bundle exec rspec spec/lib/listen/adapter_spec.rb
←[32m[Coveralls] Set up the SimpleCov formatter.←[0m
←[32m[Coveralls] Using SimpleCov's default settings.←[0m
You must use ANSICON 1.31 or later (http://adoxa.3eeweb.com/ansicon/) to use colour on Windows
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Listen::Adapter
  .new
←[32m    returns Polling adapter if forced←[0m
←[32m    returns Windows adapter when usable←[0m
←[32m    returns Darwin adapter when usable←[0m
←[32m    returns Linux adapter when usable←[0m
←[32m    returns BSD adapter when usable←[0m
    no usable adapters
←[32m      returns Polling adapter←[0m
←[32m      warns polling fallback with default message←[0m
←[32m      warns polling fallback with custom message if set←[0m
←[32m      doesn't warn if polling_fallback_message is false←[0m

Finished in 0.13102 seconds
←[32m9 examples, 0 failures←[0m

Randomized with seed 28116

←[33m[Coveralls] Submitting with config:←[0m
←[33m{
  "environment": {
    "pwd": "c:/_temp/listen",
    "rails_root": null,
    "simplecov_root": "c:/_temp/listen",
    "gem_version": "0.7.0"
  },
  "git": {
    "head": {
      "id": "'63a588b45b63da213a1292a960e5ffb69c800157'",
      "author_name": "'Thibaud Guillaume-Gentil'",
      "author_email": "'thibaud@thibaud.me'",
      "committer_name": "'Thibaud Guillaume-Gentil'",
      "committer_email": "'thibaud@thibaud.me'",
      "message": "'Release 2.1.0'"
    },
    "branch": "master",
    "remotes": [
      {
        "name": "origin",
        "url": "git@github.com:guard/listen.git"
      }
    ]
  }
}←[0m
←[36m[Coveralls] Submitting to https://coveralls.io/api/v1←[0m
←[31m[Coveralls] API internal error occured, we're on it!←[0m
Coverage is at 30.23%.
Coverage report sent to Coveralls.
$ export CI=true && bundle exec rspec spec/lib/listen/adapter
←[32m[Coveralls] Set up the SimpleCov formatter.←[0m
←[32m[Coveralls] Using SimpleCov's default settings.←[0m
You must use ANSICON 1.31 or later (http://adoxa.3eeweb.com/ansicon/) to use colour on Windows
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Listen::Adapter::Base
  #_notify_change
    listener doesn't listen
←[32m      calls change on change_pool asynchronously←[0m
    listener listen
←[32m      calls change on change_pool asynchronously←[0m
  #_latency
←[32m    returns latency from listener actor if present←[0m
←[32m    returns default_latency with listener actor latency not present←[0m

Listen::Adapter::Darwin
←[32m  isn't usable on Windows←[0m

Listen::Adapter::BSD
←[32m  isn't usable on Windows←[0m

Listen::Adapter::Polling
  .usable?
←[32m    returns always true←[0m
  #_latency
←[32m    returns latency from listener actor if present←[0m
←[32m    returns default_latency with listener actor latency not present←[0m
  #start
←[32m    notifies change on every listener directories path←[0m

Listen::Adapter::Linux
←[32m  isn't usable on Windows←[0m

Listen::Adapter::Windows
  .usable?
←[32m    requires wdm gem←[0m
←[32m    returns always true←[0m

Finished in 0.17152 seconds
←[32m13 examples, 0 failures←[0m

Randomized with seed 9577

←[33m[Coveralls] Submitting with config:←[0m
←[33m{
  "environment": {
    "pwd": "c:/_temp/listen",
    "rails_root": null,
    "simplecov_root": "c:/_temp/listen",
    "gem_version": "0.7.0"
  },
  "git": {
    "head": {
      "id": "'63a588b45b63da213a1292a960e5ffb69c800157'",
      "author_name": "'Thibaud Guillaume-Gentil'",
      "author_email": "'thibaud@thibaud.me'",
      "committer_name": "'Thibaud Guillaume-Gentil'",
      "committer_email": "'thibaud@thibaud.me'",
      "message": "'Release 2.1.0'"
    },
    "branch": "master",
    "remotes": [
      {
        "name": "origin",
        "url": "git@github.com:guard/listen.git"
      }
    ]
  }
}←[0m
←[36m[Coveralls] Submitting to https://coveralls.io/api/v1←[0m
←[31m[Coveralls] API internal error occured, we're on it!←[0m
Coverage is at 53.9%.
Coverage report sent to Coveralls.

@thibaudgg
Copy link
Member

Ok if this specs work, I really don't understand why you got

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'

with bundle exec guard --debug --guardfile "c:/path/to/Guardfile" without wdm.

As I don't have a Windows machine with c extension working I'm not able to debug wdm adapter myself, feel free to play with Listen windows adapter code and submit pull request. Thanks in advance!

Regarding polling being slow, try to ignore a maximum of useless files and change latency option.

@thibaudgg
Copy link
Member

I just release 2.1.1 with a fix on adapter, could you please give it a try with wdm.

@azt3k
Copy link
Author

azt3k commented Oct 17, 2013

Same result sorry - i.e. looks like its working at then exits - as per output above.

Will stick to 1.8.3 for the time being and will have a look at the wdm adapter when I get a chance

@thibaudgg
Copy link
Member

Ok thanks.

@isimmons
Copy link

isimmons commented Nov 4, 2013

After reading this I dropped back to 1.8.3 to test and it's working so far with sass and livereload.
Windows 7 64bit with 32bit ruby
ruby 1.9.3p429
guard-1.8.3
listen-1.3.1
guard-sass-1.3.2
guard-livereload-1.4.0

@nilliams
Copy link

nilliams commented Nov 4, 2013

listen 2.2.0
ruby 1.9.3p448 [i386-mingw32]
Windows 7 (32bit)

I can verify that simply running the Listen example in the readme, ie:

listener = Listen.to('dir/to/listen', 'dir/to/listen2') do |modified, added, removed|
  puts "modified absolute path: #{modified}"
  puts "added absolute path: #{added}"
  puts "removed absolute path: #{removed}"
end
listener.start # not blocking
sleep

... if wdm is present, then the script exits silently (despite the sleep).

With wdm not present, it works as expected.

@isimmons
Copy link

isimmons commented Nov 4, 2013

Just did the same as @nilliams by gem update followed by gem uninstall wdm and I get the following message

C:\Users\lotus\laracasts\l40>guard
14:58:54 - INFO - Guard is using TerminalTitle to send notifications.
14:58:54 - INFO - Guard is now watching at 'C:/Users/lotus/laracasts/l40'
14:58:54 - INFO - LiveReload is waiting for a browser to connect.
  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

It works like this but is extremely slow. Up to 8 second compile plus another 3 or 4 seconds for livereload to show the change in chrome.

At least with the older versions in my previous comment the change showed in the browser in 1-2 seconds.

So does this mean the problem can be narrowed down to wdm? If that was fixed so wdm could be re-installed would it speed up guard? Sorry I don't know much about how it all works.

@thibaudgg
Copy link
Member

@isimmons yes with wdm working it would be pretty fast and low cpu, polling adapter is using without wdm and it's quite slow.

@andregriffin
Copy link

Confirming same problem with guard 2.2.3, listen 2.2.0, wdm 0.1.0, ruby 1.9.3 -- silent exit

@thibaudgg
Copy link
Member

Still an issue?

@zetas
Copy link

zetas commented Feb 25, 2014

I just started using spork and guard and found this issue when my guard process was just exiting instead of continuing to watch for changes, so barring some config issue on my part, this is still an issue.

This is my gemfile:

source 'https://rubygems.org'
ruby '1.9.3'

gem 'rails', '4.0.3'
gem 'pg'

group :development, :test do
  gem 'rspec-rails', '2.13.1'
  gem 'guard-rspec', '2.5.0'
  gem 'spork-rails', '4.0.0'
  gem 'guard-spork', '1.5.0'
  gem 'childprocess', '0.5.1'
end

group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
  gem 'rb-notifu', '0.0.4'
  gem 'win32console', '1.3.2'
  gem 'wdm', '0.1.0'
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'rails_12factor', '0.0.2'
end

This is the output from rubymine when i run guard:

C:\Ruby193\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Ruby193/bin/guard
08:54:30 - INFO - Guard is using Notifu to send notifications.
08:54:30 - INFO - Guard is using TerminalTitle to send notifications.
08:54:30 - INFO - Guard::RSpec is running
08:54:30 - INFO - Running all specs
...........

Finished in 0.18202 seconds
11 examples, 0 failures

Randomized with seed 53171

  <-- Slave(2) run done!
08:54:33 - INFO - Guard is now watching at 'C:/Users/David/RubymineProjects/sample_app'

Process finished with exit code -2147483647

and my guardfile which i've simplified to eliminate variables:

# A sample Guardfile
# More info at https://github.com/guard/guard#readme
require 'active_support/inflector'

group :spec do
  guard :rspec, all_after_pass: false, cli: '--drb' do
    watch(%r{^spec/.+_spec\.rb$})
    watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
    watch('spec/spec_helper.rb')  { "spec" }
  end
end

This is my first day with guard and spork so I'm more than willing to admit it's a config issue on my part. I set this up while following the tutorial here: http://ruby.railstutorial.org/chapters/static-pages#sec-guard

@thibaudgg
Copy link
Member

@zetas I'm sorry but I've never use Spork and Guard on Windows, never see the error either.

@zetas
Copy link

zetas commented Feb 25, 2014

I need to get a frickin mac

@thibaudgg
Copy link
Member

@zetas that sounds like a great idea. And use Spring instead of Spork!

@net1957
Copy link

net1957 commented Apr 29, 2014

Get the same result as @nilliams on
windows 8.1 64b
ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

If i use the example given in wdm repo (https://github.com/Maher4Ever/wdm/blob/master/example/changes_monitor.rb), it work.

see gist https://gist.github.com/net1957/7947e78ce2b6bb13b113

Using timers 1.1.0
Using celluloid 0.15.2
Using nio4r 1.0.0
Using celluloid-io 0.15.0
Using ffi 1.9.3
Using rb-fsevent 0.9.4
Using rb-inotify 0.9.4
Using listen 2.7.3
Using wdm 0.1.0
Using bundler 1.6.2

@thibaudgg
Copy link
Member

@net1957 could you try to run the spec suite of Listen on your system and copy/paste the result here. Thanks!

@sparxsys
Copy link

sparxsys commented May 1, 2014

I am using windows 8.1 and in my case everything is working fine when I use --force-polling option but it is very slow. Takes 4-5 mins to refresh the browser.

It works fine on my iMac but I really need to get it working on my windows laptop.

@net1957
Copy link

net1957 commented May 1, 2014

D:\Dvlt\ruby\projects\_test>git clone https://github.com/guard/listen.git
Cloning into 'listen'...
remote: Counting objects: 4308, done.
remote: Compressing objects: 100% (2174/2174), done.
remote: Total 4308 (delta 2024), reused 4300 (delta 2021)
Receiving objects: 100% (4308/4308), 888.19 KiB | 139.00 KiB/s, done.
Resolving deltas: 100% (2024/2024), done.
Checking connectivity... done.

D:\Dvlt\ruby\projects\_test>pik list
  171: jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_07-b10 [Windows 8-amd64]
* 193: ruby 1.9.3p545 (2014-02-24) [i386-mingw32]
  200: ruby 2.0.0p451 (2014-02-24) [x64-mingw32]

D:\Dvlt\ruby\projects\_test>cd listen

D:\Dvlt\ruby\projects\_test\listen>bundle
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.3.1
Using bundler 1.6.2
Using timers 1.1.0
Using celluloid 0.15.2
Using nio4r 1.0.0
Using celluloid-io 0.15.0
Installing coderay 1.1.0
Using multi_json 1.9.3
Using mime-types 2.2
Using rest-client 1.6.7
Using docile 1.1.3
Using simplecov-html 0.8.0
Using simplecov 0.8.2
Installing tins 1.1.0
Installing term-ansicolor 1.3.0
Using thor 0.19.1
Installing coveralls 0.7.0
Installing diff-lcs 1.2.5
Using ffi 1.9.3
Installing formatador 0.2.4
Using rb-fsevent 0.9.4
Using rb-inotify 0.9.4
Using listen 2.7.3 from source at .
Installing lumberjack 1.0.5
Installing method_source 0.8.2
Using slop 3.5.0
Installing win32console 1.3.2
Installing pry 0.9.12.6
Installing guard 2.6.0
Installing rspec-core 2.14.8
Installing rspec-expectations 2.14.5
Installing rspec-mocks 2.14.6
Installing rspec 2.14.1
Installing guard-rspec 4.2.8
Installing rspec-retry 0.3.0
Using wdm 0.1.0
Using yard 0.8.7.4
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

D:\Dvlt\ruby\projects\_test\listen>rake spec
D:/program/dvlt/ruby/ruby193/bin/ruby.exe -S rspec ./spec/acceptance/listen_spec.rb ./spec/acceptance/tcp_spec.rb ./spec
/lib/listen/adapter/base_spec.rb ./spec/lib/listen/adapter/bsd_spec.rb ./spec/lib/listen/adapter/darwin_spec.rb ./spec/l
ib/listen/adapter/linux_spec.rb ./spec/lib/listen/adapter/polling_spec.rb ./spec/lib/listen/adapter/tcp_spec.rb ./spec/l
ib/listen/adapter/windows_spec.rb ./spec/lib/listen/adapter_spec.rb ./spec/lib/listen/change_spec.rb ./spec/lib/listen/d
irectory_spec.rb ./spec/lib/listen/file_spec.rb ./spec/lib/listen/listener_spec.rb ./spec/lib/listen/record_spec.rb ./sp
ec/lib/listen/silencer_spec.rb ./spec/lib/listen/tcp/broadcaster_spec.rb ./spec/lib/listen/tcp/listener_spec.rb ./spec/l
ib/listen/tcp/message_spec.rb ./spec/lib/listen_spec.rb
You must use ANSICON 1.31 or later (http://adoxa.3eeweb.com/ansicon/) to use colour on Windows
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Listen::TCP::Listener
  when recipient
←[32m    should be a recipient←[0m
←[32m    should not be a broadcaster←[0m
←[32m    forces TCP adapter through options←[0m
    when host is omitted
      host
←[32m        should eq "localhost"←[0m
  when broadcaster
←[32m    does not force TCP adapter through options←[0m
←[32m    should not be a recipient←[0m
←[32m    should be a broadcaster←[0m
    #block
←[32m      broadcasts changes asynchronously←[0m
←[32m      invokes original callback block←[0m
      when paused
←[32m        honours paused state and does nothing←[0m
      when stopped
←[32m        honours stopped state and does nothing←[0m
    #start
←[32m      registers broadcaster←[0m
←[32m      starts broadcaster←[0m
    when host is omitted
      host
←[32m        should be nil←[0m
  #initialize
←[32m    raises on invalid mode←[0m
←[32m    raises on omitted target←[0m
    port
←[32m      should eq 4000←[0m
    host
←[32m      should eq "10.0.0.2"←[0m
    mode
←[32m      should equal :recipient←[0m

Listen
  with one listen dir
    force_polling option to true
      hidden file in listen dir
←[32m        listens to file touch←[0m
      with only option
←[32m        listens only to file touch matching with only patterns←[0m
      nothing in listen dir
←[32m        listens to file moved inside←[0m
←[32m        listens to multiple files addition←[0m
←[32m        listens to file addition←[0m
      dir in listen dir
←[32m        listens to file touch←[0m
      file in listen dir
←[31m        listens to file modification and wait (FAILED - 1)←[0m

Failures:

  1) Listen with one listen dir force_polling option to true file in listen dir listens to file modification and wait
     ←[31mFailure/Error:←[0m ←[31m}).to eq({ modified: ['file.rb'], added: [], removed: [] })←[0m
       ←[31m←[0m
       ←[31mexpected: {:modified=>["file.rb"], :added=>[], :removed=>[]}←[0m
       ←[31m     got: {:modified=>[], :added=>[], :removed=>[]}←[0m
       ←[31m←[0m
       ←[31m(compared using ==)←[0m
       ←[31m←[0m
       ←[31mDiff:←[0m
       ←[31m←[34m@@ -1,4 +1,4 @@←[0m
       ←[31m←[0m :added => [],←[0m
       ←[31m←[31m-:modified => ["file.rb"],←[0m
       ←[31m←[0m←[32m+:modified => [],←[0m
       ←[31m←[0m :removed => []←[0m
←[36m     # ./spec/acceptance/listen_spec.rb:77:in `block (6 levels) in <top (required)>'←[0m
←[36m     # ./spec/acceptance/listen_spec.rb:59:in `block (6 levels) in <top (required)>'←[0m
←[36m     # ./spec/acceptance/listen_spec.rb:20:in `block (4 levels) in <top (required)>'←[0m
←[36m     # ./spec/support/fixtures_helper.rb:23:in `fixtures'←[0m
←[36m     # ./spec/acceptance/listen_spec.rb:20:in `block (3 levels) in <top (required)>'←[0m

Finished in 8.05 seconds
←[31m26 examples, 1 failure←[0m

Failed examples:

←[31mrspec ./spec/acceptance/listen_spec.rb:73←[0m ←[36m# Listen with one listen dir force_polling option to true file i
n listen dir listens to file modification and wait←[0m

Randomized with seed 53461

D:/program/dvlt/ruby/ruby193/bin/ruby.exe -S rspec ./spec/acceptance/listen_spec.rb ./spec/acceptance/tcp_spec.rb ./spec
/lib/listen/adapter/base_spec.rb ./spec/lib/listen/adapter/bsd_spec.rb ./spec/lib/listen/adapter/darwin_spec.rb ./spec/l
ib/listen/adapter/linux_spec.rb ./spec/lib/listen/adapter/polling_spec.rb ./spec/lib/listen/adapter/tcp_spec.rb ./spec/l
ib/listen/adapter/windows_spec.rb ./spec/lib/listen/adapter_spec.rb ./spec/lib/listen/change_spec.rb ./spec/lib/listen/d
irectory_spec.rb ./spec/lib/listen/file_spec.rb ./spec/lib/listen/listener_spec.rb ./spec/lib/listen/record_spec.rb ./sp
ec/lib/listen/silencer_spec.rb ./spec/lib/listen/tcp/broadcaster_spec.rb ./spec/lib/listen/tcp/listener_spec.rb ./spec/l
ib/listen/tcp/message_spec.rb ./spec/lib/listen_spec.rb failed

D:\Dvlt\ruby\projects\_test\listen>

To run it on windows I removed the first "/" in Pathname in silencer_spec.rb

    directories: [Pathname.new(Dir.pwd), Pathname.new("Users/Shared/")],

without that I get this error

E, [2014-05-01T10:19:37.342856 #6408] ERROR -- : Listen::Silencer crashed!
ArgumentError: different prefix: "D:/" and "/Users/Shared"
        D:/program/dvlt/ruby/ruby193/lib/ruby/1.9.1/pathname.rb:465:in `relative_path_from'
        D:/Dvlt/ruby/projects/_test/listen/lib/listen/silencer.rb:60:in `block in _relative_path'
        D:/Dvlt/ruby/projects/_test/listen/lib/listen/silencer.rb:60:in `map'
        .....

@radimklaska
Copy link

I've used
gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin/i
instead of
gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i
(running bundle exec guard in standard windows command line) and it doesn't silently exits any more...

@andregriffin
Copy link

I can confirm that using the standard command prompt instead of git bash and using the wdm config as stated above works. Using a completely updated bundle. Listen still throws a warning though about adding wdm config to my gemfile.

@e2
Copy link
Contributor

e2 commented Jun 3, 2014

Thanks guys! And thanks for your help, too.

Let me know if you have other issues - even minor edge cases.

@andregriffin - that's strange.

Are you absolutely sure you're using bundler 1.6.2?
Does bundle say 'Using wdm 0.1.0' after running bundle install or not?
Have you tried removing the Gemfile.lock and bundle install?
Does bundle show wdm say anything? (with the RbConfig condition)
Does something like: gem 'wdm', '>= 0.1.0' if true work?

Could you try putting this into your Gemfile:

result = RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i

if result
  STDERR.puts "wdm loading on: #{RbConfig::CONFIG['target_os']} (#{result.inspect})"
  gem 'wdm', '>= 0.1.0' 
else
  STDERR.puts "wdm not loading on: #{RbConfig::CONFIG['target_os']} (#{result.inspect})"
end

I just can't imagine how this can not work.

@andregriffin
Copy link

I am using bundler 1.6.2.

Using gem 'wdm', '>= 0.1.0' if true works

bundle show wdm produces this:

wdm loading on: mingw32 (0)
c:/Ruby193/lib/ruby/gems/1.9.1/gems/wdm-0.1.0

Pasting what you gave into my gemfile produces this:

wdm loading on: mingw32 (0)
wdm loading on: mingw32 (0)
wdm loading on: mingw32 (0)
20:29:09 - INFO - Reloading browser: css/site.no-query.css
20:29:11 - INFO - Reloading browser: css/site.styles.css
20:29:12 - INFO - Reloading browser: css/layouts/centered/centered.layout.no-que
ry.css
[1] guard(main)> Compilation took 6.115s
20:29:13 - INFO - Reloading browser: css/layouts/centered/centered.layout.css
[1] guard(main)> Monitoring theme files.
20:29:14 - INFO - Guard::Compass is waiting to compile your stylesheets.
20:29:14 - INFO - Guard is now watching at 'LOCALPATH'
20:29:14 - INFO - LiveReload is waiting for a browser to connect.

Just fails after LiveReload tries to connect, as it has always done...

@e2
Copy link
Contributor

e2 commented Jun 3, 2014

@andregriffin, could you set the environment variable set LISTEN_GEM_DEBUGGING=2 and then rerun guard with the debug option, e.g. bundle exec guard -d ?

It's strange if LiveReload fails because of a config check in the Gemfile - definitely seems like an unrelated issue...

@parkr
Copy link

parkr commented Jun 11, 2014

We use Listen to handle file changes in Jekyll and are running into serious problems with Listen on Windows.

An array of issues, even up to v2.7.7. Seems like 2.6.0 worked ok, 2.7.5 is broken, 2.7.6 works for some, and 2.7.7 breaks everything. Is this Listen or WDM's problem?

@e2
Copy link
Contributor

e2 commented Jun 11, 2014

@parkr - as far as I know, everything should work. Let's tackle this one by one - pick an issue (most serious first is ok) and run with LISTEN_GEM_DEBUGGING=1 (and if it doesn't show anything, run it with 2).

Also, Listen hijacks Celluloid's logger (because it's async, etc.) and Celluloid can either show irrelevant errors or silence them and show nothing, so:

  1. Run with the debug flag above
  2. Check if the behavior is as expected - if not, let me know.
  3. Don't freak out with the amount of Celluloid errors - most of them are probably harmless.

Running with the debug flag set should help me quickly identify the cause.

@e2
Copy link
Contributor

e2 commented Jun 11, 2014

Overall, Windows is a poor platform for development, while the WDM is a great job and there's no active support for Windows in Listen (should work, though it's not actively tested and none of the core devs uses Windows, there's no build options for Windows on Travis, etc.).

The current released version is expected to work - and I wouldn't consider any other version. If it doesn't work, it's a bug and I don't know about it.

@parkr
Copy link

parkr commented Jun 11, 2014

@e2 Thanks for getting back to me so quickly! Didn't know LISTEN_GEM_DEBUGGING was a thing. What are the values? I'll ask everyone to submit a stacktrace with that env var turned on. It's only on Windows that we're seeing problems and I don't have a windows computer so I can't test for them. Thanks for the tip and thanks for looking through the issues I posted.

@e2
Copy link
Contributor

e2 commented Jun 12, 2014

@parkr - it's described in the (long) README. 1 should be enough to show problems and events, 2 is full debug (probably not necessary).

Even if the problem isn't with Listen, it's useful for debugging everything else too - and especially for extracting fixtures and test/edge cases.

Listen does a ton of complex stuff under the hood, each platform has little in common with the others (in terms of how it works, possible bugs and problems) and there a tons of possible edge-cases and race-conditions that aren't prevented or don't even have defined proper behavior...

... so don't hesitate to ask about anything.

@parkr
Copy link

parkr commented Jun 12, 2014

@e2 Seem to be running into a problem with #_log:

I, [2014-06-13T01:30:36.861327 #5968]  INFO -- : Celluloid loglevel set to: 1
W, [2014-06-13T01:30:36.883328 #5968]  WARN -- : Adapter: failed: #<NoMethodErro
r: undefined method `_log' for Listen::Adapter::Windows:Class>:C:/Ruby200-x64/li
b/ruby/gems/2.0.0/gems/listen-2.7.7/lib/listen/adapter/windows.rb:21:in `rescue
in usable?'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/listen-2.7.7/lib/listen/adapter/windows.
rb:17:in `usable?'

It's been reported twice today. Here's a stacktrace with the debugging env var turned on: jekyll/jekyll#2507 (comment)

@e2
Copy link
Contributor

e2 commented Jun 12, 2014

Looks like I didn't implement _log as a class method... doh...

Either way, it's reporting that for some reason WDM failed to get required - either the wdm gem isn't installed, or it didn't get built/compiled (the Windows version of the gem should have a working compiled binary AFAIK).

@e2
Copy link
Contributor

e2 commented Jun 12, 2014

@parkr - v2.7.8 fixes this (it shows warning and falls back to polling instead of crashing)

@parkr
Copy link

parkr commented Jun 12, 2014

@parkr - v2.7.8 fixes this (it shows warning and falls back to polling instead of crashing)

Excellent! Thanks a lot.

@Ollie222
Copy link

@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' # Helps compass stats output 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.

@Ollie222
Copy link

After some further experimentation it seems that I may have found a pattern for my setup.

In my gemfile if I comment out the line gem 'wdm' line' like this

require 'rbconfig'
if RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i
#gem 'wdm', '>= 0.1.0'
end

and then start it with bundle exec guard it starts as mentioned before and works ok.

If after it starts I then type 'exit', uncomment the gem 'wdm' line like this

require 'rbconfig'
if RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i
gem 'wdm', '>= 0.1.0'
end

and then start it again with bundle exec guard it now works and it looks to be using wdm, cpu usage is very low and any changes are detected much more quickly (3 seconds versus about 10).

If I exit this and try to restart it it silently exits at the start and this is regardless of how many times I try to restart it. The only thing that makes it work is to again comment out the gem 'wdm' line, start and exit it, uncomment it and then start it again.

Hopefully this extra info may provide some extra clues.

One other thing I note is that the livereload is unreliable if I have more than one browser window to the same dev site open at the same time.

@e2
Copy link
Contributor

e2 commented Sep 14, 2014

@Ollie222 - listen comes with a "listen" tool to just print files that change - without running guard, etc.

Just run listen and change some files - should run forever and report all changes without issues. And if that doesn't work, try e.g. on an empty folder and create a file there.

Because at this point, you want to know if the problem is with listen or guard.

(After 'wdm - starting ...' you should see 'wdm - callback: (...)' whenever you change a watched file).

Once listen is working perfectly by itself, we can work out what else could be wrong...

@Ollie222
Copy link

@e2 - Thank you for the quick response.

This is my first exposure to Ruby so I'm still learning a lot of the basics.

If I just type listen at the command prompt then it just says 'Starting listen...' and then exists. I'm not sure if this is intended behaviour or not.

In a new folder I've just added a gemfile with the following contents and called 'bundle install'.

source 'https://rubygems.org'
gem 'listen' # Guard event handler.
gem 'celluloid-io'

I've then created a file called test.rb and added the script below to it.

require 'listen'
path = 'C:\ruby-files'
puts path
listener = Listen.to(path) do |modified, added, removed|
puts "modified absolute path: #{modified}"
puts "added absolute path: #{added}"
puts "removed absolute path: #{removed}"
end
listener.start # not blocking
sleep

When I run the above script it outputs the path name and then just sits there. If I add, delete or alter any files in the monitored directory then the file detail changes are shown in the terminal.

If I have more than 58 files in the directory being monitored then the script starts and exits after a few seconds.

Is there a memory setting that needs to be increased or does this provide any more clues as to what to test next?

Thanks again for your help.

@e2
Copy link
Contributor

e2 commented Sep 15, 2014

@Ollie222 - if your scripts stops after a few seconds, it means something silently crashed.

Just set the environment variable: set LISTEN_GEM_DEBUGGING=2 before running your script, and it should display errors and crashes. (And paste the output).

@Ollie222
Copy link

Thanks again for your quick reply.

With LISTEN_GEM_DEBUGGING=2 it gives the following output before exiting.

I, [2014-09-15T15:12:05.946292 #11712] INFO -- : Celluloid loglevel set to: 0
D, [2014-09-15T15:12:05.968293 #11712] DEBUG -- : Adapter: considering TCP ...
D, [2014-09-15T15:12:05.969293 #11712] DEBUG -- : Adapter: considering polling ...
D, [2014-09-15T15:12:05.971294 #11712] DEBUG -- : Adapter: considering optimized backend...
I, [2014-09-15T15:12:06.082300 #11712] INFO -- : Record.build took 0.03300213813781738 seconds
D, [2014-09-15T15:12:06.084300 #11712] DEBUG -- : wdm - starting...

It looks like it's starting wdm even though I've not got it specified in the gem file.

With debugging on if I now have 53 or fewer items in the directory then it works with wdm, any more and it exits silently.

If I change the listen.to to include force_polling:true then with debugging mode on it lists the file names in the specified directories every second or so and it looks to work with any number of files although it took about 30 seconds to check a folder with 22,000 files in it which I presume is to be expected.
.

@e2
Copy link
Contributor

e2 commented Sep 15, 2014

@Ollie222 - any strange names in the files?

Other than that I have no clue at this point. You could try a newer version of Ruby maybe (to see if anything is different). Maybe even a 'bundle update' to make sure you have a newer version of Celluloid.

You can try adding more debug statements in the adapters/windows.rb file - to see when it exits.

Either way, your problem seems strange (you should at least see errors or something).

When you have more than 53 files - does it exit even if you do nothing (i.e. no files changed)?

@Ollie222
Copy link

I'm currently using 1.9.3 as this is what seems to be suggested as the most compatible but I'll try a later version of Ruby.

Bundle update shows

Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Using hitimes 1.2.2
Using timers 4.0.1
Using celluloid 0.16.0
Using nio4r 1.0.1
Using celluloid-io 0.16.0
Using ffi 1.9.3
Using rb-fsevent 0.9.4
Using rb-inotify 0.9.5
Using listen 2.7.9
Using rb-fchange 0.0.6
Using wdm 0.1.0
Using bundler 1.7.2
Your bundle is updated!

I believe the above is about as up to date as available for stable versions. (I've added back in wdm)

It either works perfectly with a smaller number of files or it just exits a second or so after starting before any file changes have taken place.

Am I right in thinking that adapters.rb is part of compass, if so I don't think my test project uses it.

I It certainly seems a bit of an odd issue and once again thanks for your time trying to help, I'll update the thread if I get anywhere.

@e2
Copy link
Contributor

e2 commented Sep 15, 2014

You can use bundle show listen to find out where Listen's files are and add debug logs to adapter/windows.rb like here: https://github.com/guard/listen/blob/master/lib/listen/adapter/windows.rb#L30

Basically, you'd want to know whether the _configure method finishes and if the _run method does too.

You could also try an earlier version of Listen (between 2.7.0 and master) - just to compare if it works any different (you won't see any debug messages - but you can check if it exits or not).

Anyway, without some serious poking around with the wdm adapter (windows.rb file above), I have no idea what could be wrong.

(afterwards, gem pristine listen should undo any change you make to listen's source files)

@Ollie222
Copy link

Thanks for the advice.

I've added a couple of debug messages to the windows.rb file.

  def _configure(dir, &callback)
    require 'wdm'
    _log :debug, 'wdm - starting...'
    @worker ||= WDM::Monitor.new
    _log :debug, 'wdm - stage 1'
    @worker.watch_recursively(dir.to_s, :files) do |change|
      callback.call([:file, change])
    end
    _log :debug, 'wdm - stage 2'

    @worker.watch_recursively(dir.to_s, :directories) do |change|
      callback.call([:dir, change])
    end

    events = [:attributes, :last_write]
    @worker.watch_recursively(dir.to_s, *events) do |change|
      callback.call([:attr, change])
    end
  end

  def _run
    _log :debug, 'wdm - worker run'
    @worker.run!
  end

When executed I now get

wdm - starting...
wdm - stage 1

If I'm understanding correctly it's not calling and returning from watch_recursively which I believe is part of the wdm gem.

Also the directory and file names are simple and making them shorter makes no difference to the maximum number of files.

@e2
Copy link
Contributor

e2 commented Sep 23, 2014

@Ollie222 - this probably needs compiling a debug version of wdm and/or putting debug statements there.

Personally, I avoid Windows like the plague (and I have a grudge against Microsoft products), so it's unlikely I'll spend time helping you debug this on the wdm side. Of course, if there's anything I can fix in Listen itself (or provide a workaround), I'd be happy to.

The best thing I can recommend is trying out Ruby 2.1.2 (or other versions) to see if there's any change (there were some memory allocation issues - see current/close wdm issues for possible info/tips, e.g. Maher4Ever/wdm#15).

@Ollie222
Copy link

@e2 - Thanks for your advice again and I wasn't expecting you to fix the issue, you've given me lots to go on and issue does look to be with wdm and Windows.

I have to use a number of different platforms for different projects but for this one getting it working on Windows would be useful.

I will try out a later version of Ruby and also checkout the wdm issues list. I'll report back if I get anywhere.

Once again thanks for your help.

@e2
Copy link
Contributor

e2 commented Sep 23, 2014

@Ollie222 - no problem. I hope I didn't come across as being irritated or something - I just have too many personal reasons not to get my hands dirty with this. While windows is a "user friendly" platform, it's also a very "developer-unfriendly" platform (IMHO).

I feel sad for Windows users that they have so many exotic issues - and I feel for the independent developers out there spending tons of time trying to deal with them (I used to be one of them - ages ago) and getting almost no credit and/or long-term satisfaction.

(I'm always astounded to see so many brilliant people doing incredible things to make Ruby apps and libraries work on Windows).

Just to make myself clear - I'd love to make listen work perfectly on Windows (and I've spent a lot of time to make it work and keep it working) and thumbs up for anyone willing to dive into this. It's just that by being a "Windows repair-man" I feel like I'm contributing to the problem instead of fixing it.

So while I don't want to get my hands dirty with this, I also don't want to discourage others from asking for help with similar issues and/or from making contributions in listen towards Windows support.

@DirtyF
Copy link

DirtyF commented Dec 4, 2016

This seems to affect Jekyll users under Windows (jekyll/jekyll#5629)

@andrii-pukhalevych
Copy link

Windows 7 32bit, Ruby 2.9, Compass 1.0.3, rb-inotify-0.10.1
compass watch still causes high CPU load

@ColinDKelley
Copy link
Collaborator

If this problem persists with v3.3 and anyone's interested, let us know and we can reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests