# Re: Open4 : undefined method \`spawn'

**URL:** <https://www.ruby-forum.com/t/re-open4-undefined-method-spawn/147602>\
**Category:** Ruby\
**Created:** [September 3, 2008, 3:22pm UTC](https://www.ruby-forum.com/t/re-open4-undefined-method-spawn/147602 "2008-09-03T15:22:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [September 3, 2008, 3:22pm UTC](https://www.ruby-forum.com/t/re-open4-undefined-method-spawn/147602/1 "2008-09-03T15:22:47Z")

</div>

> seems strange to me because the method spawn IS defined in the “module  
> Open4” (lines 241-320)

“include Mod” gives you access to the instance methods of the module,  
but  
not module methods. See [class Module - RDoc Documentation](http://www.ruby-doc.org/core/classes/Module.html)

irb(main):001:0\> module Foo; def test1; puts “hello”; end; end  
=\> nil  
irb(main):002:0\> module Bar; def self.test2; puts “bye”; end; end  
=\> nil  
irb(main):003:0\> include Foo  
=\> Object  
irb(main):004:0\> include Bar  
=\> Object  
irb(main):005:0\> test1  
hello  
=\> nil  
irb(main):006:0\> test2  
NameError: undefined local variable or method `test2’ for main:Object  
from (irb):6  
from :0  
irb(main):007:0\> Bar.test2  
bye  
=\> nil

So I haven’t tried the Open4 gem, but probably you need “Open4.spawn”

Regards,

Brian.
