Open4 : undefined method `spawn'

I’m trying some samples of open4-0.9.6 :


#! /usr/bin/env ruby

require ‘rubygems’
require ‘open4’
include Open4

cat = ‘ruby -e" ARGF.each{|line| STDOUT << line} "’

stdout, stderr = ‘’, ‘’
status = spawn cat, ‘stdin’ => ‘42’, ‘stdout’ => stdout, ‘stderr’ =>
stderr
p status
p stdout
p stderr

stdout, stderr = ‘’, ‘’
status = spawn cat, 0=>‘42’, 1=>stdout, 2=>stderr
p status
p stdout
p stderr

I’ve just added the shebang and “require ‘rubygems’” to the original
file.
When running it, i get :
./spawn.rb:10: undefined method `spawn’ for main:Object (NoMethodError)

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

any idea ?

On Sep 3, 2008, at 6:19 AM, Une Bévue wrote:

p stdout
Open4" (lines 241-320)

any idea ?

Une Bévue

it does seems strange. for me:

cfp:~ > sudo gem install open4
Successfully installed open4-0.9.6
1 gem installed

cfp:~ > ruby -r rubygems -e’ require “open4” and include Open4 and
spawn “echo 42”, :stdout => STDOUT and p Open4.version ’
42
“0.9.6”

a @ http://codeforpeople.com/

-------- Original-Nachricht --------

Datum: Thu, 4 Sep 2008 04:42:56 +0900
Von: “ara.t.howard” [email protected]
An: [email protected]
Betreff: Re: Open4 : undefined method `spawn'

include Open4
stdout, stderr = ‘’, ‘’
(NoMethodError)
it does seems strange. for me:
“0.9.6”

Hi —

what platform are you on ?
I tried the code you posted and it works fine on my Ubuntu box.
That said, I came across some quite mysterious errors on previous
installs of various gems, sent some
mails to this and other lists, where the authors said, “I’ve just tried
the software on a fresh
install of Ubuntu, and it works.”
Then I freshly installed Ubuntu, and it worked… never found out what
the error was …
presumably some path issue with ruby installed in multiple ways …

Just guessing …

Best regards,

Axel

On Sep 3, 2008, at 2:10 PM, Axel E. wrote:

Hi —

what platform are you on ?

osx.

Just guessing …

Best regards,

Axel

all the distros, including osx and ubuntu completely hose ruby. that
includes redhat enterprise, etc, etc. i always build ruby from src:

./configure --prefix=/usr/local/ && make && sudo make install

even on windows (using msys) this has been my preferred method of
installing ruby. i too have heard of issues with ubuntu.

sorry i can’t be of more help.

cheers.

a @ http://codeforpeople.com/

Axel E. [email protected] wrote:

what platform are you on ?

MacOS X 10.4.11
ruby 1.8.6 (2007-09-24 patchlevel 111) [powerpc-darwin8.11.0]
MacPorts install (under /opt/local)