From: "inversion (Yura Babak)" Date: 2021-10-08T05:57:56+00:00 Subject: [ruby-core:105604] [Ruby master Bug#18244] Unexpected errors output order Issue #18244 has been updated by inversion (Yura Babak). >I believe the real issue here is to $stderr.sync = false, why do you do that? >That's like explicitly breaking what you are asking. Having buffered `$stdout` I thought that `$stderr.sync = false` will make `$stderr` to be in sync with `$stdout`. Now I understand that it was not the best solution. >why are you writing so much to stderr I don't, I only wanted to see the error in the right place among many regular buffered outputs. >Maybe you want something like $stderr = $stdout so both are actually the same and use a single buffer? I just tested it and yes, it is exactly what I wanted to achieve ��� **single buffered output for all**. Thank you very much! ---------------------------------------- Bug #18244: Unexpected errors output order https://bugs.ruby-lang.org/issues/18244#change-94085 * Author: inversion (Yura Babak) * Status: Feedback * Priority: Normal * ruby -v: Ruby v3.0.2.107 (2021-07-07) [x64-mingw32] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Having this code: ```ruby # $stderr.sync = false warn 'warn' $stderr.puts 'err' fail ``` When I run it like this `ruby test.rb 2>err.log`, output is ok: ``` warn err test.rb:3:in `
': unhandled exception ``` But when I uncomment the first line ��� the output is different: ``` warn test.rb:3:in `
': unhandled exception err ``` Why buffered output to the `$stderr` redirected to file has the **wrong order**? If we do not redirect to the file ��� the order is ok (exception is the last line of the output). Checked platforms: `Windows10: Ruby v3.0.2.107 (2021-07-07) [x64-mingw32]` `Linux: Ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]` -- https://bugs.ruby-lang.org/ Unsubscribe: