guard / guard-spork

Guard::Spork automatically manage Spork DRb servers
https://rubygems.org/gems/guard-spork
MIT License
296 stars 58 forks source link

NotImplementedError: fork() function is unimplemented on this machine #47

Closed belgoros closed 12 years ago

belgoros commented 12 years ago

I followed the railscasts on Spork at http://railscasts.com/episodes/285-spork and got the below error when running 'guard' command:

C:\Documents and Settings\A187589\Mes documents\ror\test_apps\blog>guard
Please install rb-fchange gem for Windows file events support
Using polling (Please help us to support your system better than that).
Guard is now watching at 'C:/Documents and Settings/A187589/Mes documents/ror/test_apps/blog'
'ps' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
'ps' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
Starting Spork for Test::Unit & RSpec & Cucumber
ERROR: Guard::Spork failed to achieve its <start>, exception was:
NotImplementedError: fork() function is unimplemented on this machine
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-spork-0.3.1/lib/guard/spork/runner.rb:40:in `fork'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-spork-0.3.1/lib/guard/spork/runner.rb:40:in `spawn_child'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-spork-0.3.1/lib/guard/spork/runner.rb:23:in `launch_sporks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-spork-0.3.1/lib/guard/spork.rb:17:in `start'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:322:in `block in run_supervised_task'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:320:in `catch'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:320:in `run_supervised_task'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:153:in `block in start'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:254:in `block (3 levels) in run_on_guards'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:253:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:253:in `block (2 levels) in run_on_guards'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:252:in `catch'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:252:in `block in run_on_guards'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:251:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:251:in `run_on_guards'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard.rb:152:in `start'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/lib/guard/cli.rb:68:in `start'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/guard-0.8.8/bin/guard:6:in `<top (required)>'
C:/Ruby192/bin/guard:19:in `load'
C:/Ruby192/bin/guard:19:in `<main>'

Guard::Spork has just been fired
Guard::RSpec is running, with RSpec 2!

Here are my configuration details:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.7.2
  - RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby192/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: C:/Ruby192/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby192/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby192/lib/ruby/gems/1.9.1
     - U:/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

Rails 3.1.1 spork (0.9.0.rc9 x86-mingw32) guard (0.8.8) guard-rspec (0.5.1, 0.5.0) guard-spork (0.3.1) rspec (2.7.0) rspec-core (2.7.1, 2.7.0) rspec-expectations (2.7.0) rspec-mocks (2.7.0) rspec-rails (2.7.0)

Is it a normal behavior for Windows-like OS? Thanks.

thibaudgg commented 12 years ago

Yep, read [this issue]{https://github.com/guard/guard-spork/issues/34}.

belgoros commented 12 years ago

ok, thanks a lot. So, as far as I understood, officially there is no way to use it on Windows, running tests there is a real headache :(

thibaudgg commented 12 years ago

Yep, using a Mac/Linux machine is the way to go. Sorry.

Pauloparakleto commented 3 years ago

ok, thanks a lot. So, as far as I understood, officially there is no way to use it on Windows, running tests there is a real headache :(

@belgoros See the Rails test guides, section 3.2 to change workers -- which use the said fork(method) to paralleled processes -- to threads. This last one use another method to parallel processes. Also take a look on the beginning of the section 3, which describes how the tests are made. I have used a WSL2 to run Rails. However the local test needs the jruby to be executed in somewhat.

To change the parallelization method to use threads over forks put the following in your test_helper.rb

class ActiveSupport::TestCase

parallelize(workers: :number_of_processors, with: :threads)

end

After, specify in your command rails test how much workers you need, such as PARALLEL_WORKERS=1 rails test or PARALLEL_WORKERS=15 rails test.

A few months ago I got sad since I realize as you there is no way to test rails on Windows Machine. Yesterday, I could do my first test on Rails in my Windows. I use a WSL2. But it is not enough to run the tests. In somewhat, the local test uses the windows threads instead of fork() method.

And welcome again to Windows :)