I have just been trying to get fcgi to run under 1.8.0, and I have found a
problem:
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:476: warning: assignment to $stdout is deprecated; use STDOUT.reopen() instead
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:476:in each_cgi': $stdout is a read-only variable (NameError) from /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:473:in
each’
from /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:473:in `each_cgi’
(One problem is that Ruby gives both a warning and an error; either
assignment should be allowed with a warning, or disallowed, not both
This is caused by the following code:
$stdout, $defout, $stderr = request.out, request.out, request.err
Now, ‘request.out’ and ‘request.err’ are objects which respond to IO-like
calls, but are not actually IO objects (following the Ruby principle of Duck
Typing).
However, I now can’t change $stdout/$stderr, and nor can I reopen them since
the new objects are not IO:
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:475:in `reopen’: cannot convert FCGI::Stream into IO (TypeError)
I guess this makes sense, since $stdout/$stderr are supposed to refer to the
actual system standard input/standard output channels attached to the
process.
So it looks like the best I can do now is:
$defout, $deferr = request.out, request.err
although in that case, any existing programs which do
$stderr.puts "Some warning message"
are now going to send to the system stderr rather than the fastcgi “stderr”.
Anyway, I think the attached patch does the job for ruby-fcgi, although I’ve
not actually tested it under 1.6.8
Cheers,
Brian.
ruby-fcgi-180patch (1.54 KB)