guard / guard-spork

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

jruby(9.1.5.0) with guard-spork(2.1.0) get "yield called out of block" error #136

Open WoolenWang opened 7 years ago

WoolenWang commented 7 years ago

dear alll i am useing jruby with guard-spork get an error output :

14:44:21 - ERROR - Guard::Spork failed to achieve its , exception was: LocalJumpError: yield called out of block org/jruby/ext/win32ole/RubyWIN32OLE.java:66:in each' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-spork-2.1.0/lib/guard/spork/spork_windows_instance.rb:51:inspork_processes' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-spork-2.1.0/lib/guard/spork/spork_windows_instance.rb:20:in spork_pids' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-spork-2.1.0/lib/guard/spork/runner.rb:46:inkill_global_sporks' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-spork-2.1.0/lib/guard/spork.rb:18:in start' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/runner.rb:82:inblock in _supervise' org/jruby/RubyKernel.java:1115:in catch' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/runner.rb:79:in_supervise' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/runner.rb:22:in block in run' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/runner.rb:119:inblock in _run_group_plugins' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/runner.rb:117:in block in _run_group_plugins' org/jruby/RubyKernel.java:1115:incatch' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/runner.rb:116:in _run_group_plugins' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/runner.rb:21:inblock in run' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/runner.rb:20:in block in run' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/lumberjack-1.0.10/lib/lumberjack.rb:32:inunit_of_work' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/runner.rb:18:in run' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/commander.rb:34:instart' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/cli/environments/valid.rb:16:in start_guard' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/guard-2.14.0/lib/guard/cli.rb:122:instart' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/thor-0.19.1/lib/thor/command.rb:27:in run' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/thor-0.19.1/lib/thor/invocation.rb:126:ininvoke_command' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/thor-0.19.1/lib/thor.rb:359:in dispatch' E:/running/jruby-9.1.5.0/lib/ruby/gems/shared/gems/thor-0.19.1/lib/thor/base.rb:440:instart'

when i watch the code inguard/spork/spork_windows_instance.rb :

def self.spork_processes require "win32ole" WIN32OLE.connect("winmgmts://.").InstancesOf("win32_process"). each. select do |p| p.commandline =~ /spork|ring_server|magazine_slave_provider/ && File.basename(p.executablepath, File.extname(p.executablepath)) =~ /^(cmd|ruby)$/i end. map { |p| {:pid => p.processid, :ppid => p.parentprocessid} } end

i findout after WIN32OLE.connect("winmgmts://.").InstancesOf("win32_process") jruby return the WIN32OLE class instance is not complete same with c-ruby its each method require a block here is the example i have try: ==========================jruby 9.1.5.0 ========================================== irb(main):001:0> require 'win32ole' => true irb(main):002:0> a = WIN32OLE.connect("winmgmts://.").InstancesOf("win32_process") => #WIN32OLE:0x102881e irb(main):003:0> a => #WIN32OLE:0x102881e irb(main):007:0> a.methods => [:method_missing, :[], :dispatch, :type_info, :ole_free, :ole_method_help, :ole_get_methods, :ole_func_methods, :invoke, :_setproperty, :each, :ole_typelib, :setproperty, :ole_methods, :ole_obj_help, :_invoke, :_getproperty, :[]=, :initialize, :ole_method, :ole_put_methods, :ole_type, :SafeStringValue, :methods_with_flag, :registry_subkey, :WIN32OLE_TYPEValue, :find_all_methods_in, :typeinfo_from_ole, :search_registry, :all_methods, :load_typelib, :typedesc_value, :all_vars, :reg_each_key_for, :typelib_registry_each_guid_version, :find_all_typeinfo, :include_class, :handle_different_imports, :java_kind_of?, :public_send, :frozen?, :protected_methods, :java_implements, :public_method, :freeze, :java, :singleton_methods, :untaint, :javafx, :enum_for, :private_methods, :method, :object_id, :instance_variables, :extend, :itself, :instance_variable_set, :respond_to?, :java_name, :hash, :methods, :to_java, :java_package, :singleton_class, :public_methods, :to_enum, :display, :tainted?, :instance_variable_defined?, :untrusted?, :define_singleton_method, :nil?, :!~, :com, :instance_of?, :java_require, :javax, :java_signature, :to_s, :===, :tap, :java_annotation, :inspect, :send, :trust, :instance_variable_get, :is_a?, :eql?, :java_field, :remove_instance_variable, :untrust, :<=>, :class, :=~, :org, :taint, :kind_of?, :clone, :dup, :==, :!, :equal?, :instance_exec, :id, :instance_eval, :send, :!=] irb(main):008:0> a.each LocalJumpError: yield called out of block from org/jruby/ext/win32ole/RubyWIN32OLE.java:66:in each' from (irb):8:in' from org/jruby/RubyKernel.java:995:in eval' from org/jruby/RubyKernel.java:1296:inloop' from org/jruby/RubyKernel.java:1115:in catch' from org/jruby/RubyKernel.java:1115:incatch' from jirb:13:in `

' irb(main):009:0> a.each {|one| puts one}

WIN32OLE:0x12872e1

WIN32OLE:0x910148

WIN32OLE:0x156875e

WIN32OLE:0x14bac49

WIN32OLE:0x1d07cbb

WIN32OLE:0x171b748

WIN32OLE:0x96bacf

==========================jruby 9.1.5.0 ========================================== here is c-ruby i have try::

==========================c-ruby 2.3 ========================================== irb(main):001:0> require 'win32ole' => true irb(main):010:0> a = WIN32OLE.connect("winmgmts://.").InstancesOf("win32_process") => #WIN32OLE:0x2e024f8 irb(main):011:0> a.each => #< Enumerator : #< WIN32OLE :0x2e024f8 >:each> irb(main):012:0> a.each {|one| puts one}

WIN32OLE:0x2e23990

WIN32OLE:0x2e0fd58

WIN32OLE:0x2e0fb78

WIN32OLE:0x2e0f830

WIN32OLE:0x2e0f470

==========================c-ruby 2.3 ==========================================