RubyScript2Exe in Cygwin and gets/readline: unexpected EOFEr


I’m planning on distributing software using the very helpful
RubyScript2Exe tool. However, I’ve found that, when used on Windows
with Cygwin, it has some unexpected behaviour with the IO#gets /
IO#readline method(s). A script as simple as

foo = $stdin.gets
puts foo

reproduces this for me. Run normally, it works as expected, but when
compiled with RubyScript2Exe, gets doesn’t do anything, and foo is
actually nil. Using readline instead, I get an EOFError:

$ ./input-test.exe
c:/WINNT/TEMP/eee.input-test.exe.3/app/input-test.rb:2:in `readline’:
end of file reached (EOFError)
from c:/WINNT/TEMP/eee.input-test.exe.3/app/input-test.rb:2
from c:/WINNT/TEMP/eee.input-test.exe.3/bootstrap.rb:41

I suspected that $/, $_ or $stdin might behave or be set differently
when in this environment, but that doesn’t appear to be the case. Both
when run through ‘normal’ Ruby as well as when compiled, $/ is \0, $_
returns what I wrote and $stdin is #IO:0x*.

During the “tracing”, the test script still behaves as expected; it
only occurs in compiled form.

Also, I cannot reproduce this problem at all when using RubyScript2Exe
on Darwin (OS X), so it must be Cygwin-related. Due to socket blocking
problems, I cannot use VC+±ruby or MinGW-ruby either.

I couldn’t find anything about this in the documentation or in this
list or elsewhere on the web, but I’m probably just missing the

Any help greatly appreciated.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs