You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JRuby stderr stream redirected with standard ">" redirect #58
JRuby 9.3.15, 9.4.12.1, 10.0.1.0 on - all versions exhibited same behaviors
Ruby tests on Ruby 2.6.10
Win11Pro 26100.4652
Code:
bugtest.rb containing only these two lines:
puts"stdout"
$stderr.puts"stderr"
Expected Behavior
Command line redirect ">" should redirect stdout stream but not stderr stream. stderr stream should remain writing to console unless stderr-specific redirect used (e.g. "2>"). Ruby 2.6.10 performs as expected:
This is quite surprising. I would have expected someone to have reported this issue a long time ago. Could you run jruby --environment and provide the output?
This concerns me a bit. Running jruby in a normal way you should not see those warnings, because we pass that flag for you. Perhaps you are running jruby other than through our normal launcher executable? If you are using that standard executable, it could be missing appropriate flags to enable certain IO access we need.
Windows support in JRuby has tended to lag behind a bit when it comes to integrating with the native IO and subprocess systems. It still seems more broken than I would expect it to be. I have no theories yet as to why stdout and stderr would be combined like this.
> java -version
java version "1.8.0_461"
Java(TM) SE Runtime Environment (build 1.8.0_461-b11)
Java HotSpot(TM) Client VM (build 25.461-b11, mixed mode, sharing)
Same results observed upon switching to OpenJDK 24:
> java -version
openjdk version "24" 2025-03-18
OpenJDK Runtime Environment (build 24+36-3646)
OpenJDK 64-Bit Server VM (build 24+36-3646, mixed mode, sharing)
mockup program execution full output:
Using JRuby 9.3.15 via path set in ENV:
> jruby bugtest.rb
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by org.jruby.util.StringSupport (file:/c:/jruby-9.3.15.0/lib/jruby.jar)
WARNING: Please consider reporting this to the maintainers of class org.jruby.util.StringSupport
WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.kenai.jffi.internal.StubLoader in module org.jruby.dist (file:/c:/jruby-9.3.15.0/lib/jruby.jar)
WARNING: Use --enable-native-access=org.jruby.dist to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled
stdout
stderr
Using JRuby 10.0.1.0:
> C:\jruby-10.0.1.0\bin\jruby.bat .\bugtest.rb
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.kenai.jffi.internal.StubLoader in module org.jruby.dist (file:/C:/jruby-10.0.1.0/lib/jruby.jar)
WARNING: Use --enable-native-access=org.jruby.dist to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled
stdout
stderr
Did you mean for me to run jruby --properties? I can paste and link that.
JRuby 9.3.15:
> C:\jruby-9.3.15.0\bin\jruby.bat --environment
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by org.jruby.util.StringSupport (file:/C:/jruby-9.3.15.0/lib/jruby.jar)
WARNING: Please consider reporting this to the maintainers of class org.jruby.util.StringSupport
WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
jruby: unknown option --environment
The fact that the environment flag doesn't exist shows me how out of date the windows executable is. I'll try to think through some options for improving that situation.
Are you using CMD or PS? The warnings do not happen for me and I am seeing separation of stdout and stderr. I half makes me think the wrong jruby.jar is picked up. Can you make sure with jruby -v that it is printing out the right version?
jruby/jruby#9038 adds several manifest entries to open packages and allow native access, which may mitigate this somewhat. However I believe this is mostly an issue with the native launcher on Windows not passing the appropriate flags. I'm going to move the issue there and we will address it in the launcher.
Activity
headius commentedon Jul 31, 2025
This is quite surprising. I would have expected someone to have reported this issue a long time ago. Could you run
jruby --environmentand provide the output?This concerns me a bit. Running jruby in a normal way you should not see those warnings, because we pass that flag for you. Perhaps you are running jruby other than through our normal launcher executable? If you are using that standard executable, it could be missing appropriate flags to enable certain IO access we need.
Windows support in JRuby has tended to lag behind a bit when it comes to integrating with the native IO and subprocess systems. It still seems more broken than I would expect it to be. I have no theories yet as to why stdout and stderr would be combined like this.
adamsnd commentedon Jul 31, 2025
Java version in case that makes a difference:
Same results observed upon switching to OpenJDK 24:
mockup program execution full output:
Using JRuby 9.3.15 via path set in ENV:
Using JRuby 10.0.1.0:
jruby --environment
I don't see --environment listed as an option on https://github.com/jruby/jruby/wiki/JRubyCommandLineParameters
Did you mean for me to run
jruby --properties? I can paste and link that.JRuby 9.3.15:
JRuby 10.0.1.0:
headius commentedon Jul 31, 2025
The fact that the environment flag doesn't exist shows me how out of date the windows executable is. I'll try to think through some options for improving that situation.
enebo commentedon Jul 31, 2025
I am wondering what is going on. I am on windows 10 but this all works for me:
Are you using CMD or PS? The warnings do not happen for me and I am seeing separation of stdout and stderr. I half makes me think the wrong jruby.jar is picked up. Can you make sure with
jruby -vthat it is printing out the right version?adamsnd commentedon Jul 31, 2025
Both CMD and Powershell give the same responses to
jruby --environmentand the stdout/stderr redirect test with JRuby 10.0.1.0 and OpenJDK 24.After changing path ENV from JRuby 9.3 to C:\jruby-10.0.1.0\bin:
Add opens and native access to all jar manifests
Add opens and native access to all jar manifests
headius commentedon Oct 24, 2025
jruby/jruby#9038 adds several manifest entries to open packages and allow native access, which may mitigate this somewhat. However I believe this is mostly an issue with the native launcher on Windows not passing the appropriate flags. I'm going to move the issue there and we will address it in the launcher.
See #57 for a similar issue.