IO::BINARY is for O_BINARY which comes from underlying runtimes, and unrelated to ruby encodings.
The second form is for specifying such flags in a fine-grained manner, so it needs an encoding explicitly unlike the shorthand "wb".
I still think at least the documentation should be updated to mention this, because the current wording makes me think the alternatives I tried should be equivalent and both work: https://ruby-doc.org/core-3.1.2/IO.html#method-c-new.
I still think at least the documentation should be updated to mention this
Suggestions for improvement are of course welcome.
Note that the current document says that "b" means "setting the encoding as binary and disabling line code conversion" and File::BINARY means just "disabling line code conversion".