-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STDOUT redirect fails in JRuby #4855
Comments
There's two possibilities. The first is due to differences in how IO is implemented on Windows versus on UNIX in JRuby. Because Windows POSIX is a little spotty in places, we need to use win32 functions to emulate Ruby behavior. We have not done this work yet. It could affect reopening stdio streams because on Windows they just wrap the ones the JDK provides, rather than being true native streams. The second is due to our implementation of Readline, which currently uses a Java library called jline. Unfortunately this library takes over the stdio streams, breaking code like yours that wants to be in IRB and still redirect stdio. On my macos system, your code appeared to work just fine, which makes me think it's not directly a jline problem. FWIW, this may be the same problem (or similar) as #1372. See also #3721. |
Apologies if I didn't mention it, but yes this problem seems exclusive to windows. It is part of a larger problem. We have a Sinatra application that runs fine on Mac and Linux (using these APIS). On windows these APIS cause the application to just die. No Exceptions, just death... |
How does this affect a Sinatra application? |
Again apologies for my lack of clarity... The Sinatra app runs in MRI ruby. When I bring it up it does it's initial babbling and then it just dies, without any exception, but only on Windows. Mac and Linux users have no problems. I begin to suspect it was the 'STDOUT.reopen' that was causing the issues. Out of curiosity, I tried it in JRuby. When JRuby returned:
and MRI Ruby appeared to lock up I thought I had found the first instance of a bug on Windows MRI Ruby that JRuby could handle. It took further digging before I realized what was going on. It motivated the diff (I will place it last) where I pulled out those redirects. It results in the Sinatra app working on Windows, Linux, and Mac. Again, this app runs via MRI. I just thought I should write up the JRuby bug. Perhaps I stumbled upon a case where two wrongs make a right.
|
Ahh ok, so this isn't something unique to Sinatra; it would affect any library that attempts to redirect STDOUT using reopen on Windows. I thought that reopen used to work even with the JDK streams. Perhaps we regressed. |
Most likely to happen with Windows IO work in 9.2 (unstarted). |
This is likely still an issue due to the lack of native IO support on Windows, which will not be ready for 9.3. |
Consider the following irb session in MRI ruby:
At this point the the irb session appears to lock up, but it isn't really...
Into the irb session I will type:
But I will not see that I typed it here, nor will I see the output. Where is it?
Let us try JRuby:
JRuby will not create the file, MRI ruby does... I will do this:
Trying again:
Yields:
Why aren't the two consistent?
Thanks,
Cris
The text was updated successfully, but these errors were encountered: