Skip to content

Weak guarantees for IO#write override #434

@itarato

Description

@itarato

During CI bug investigation we noticed this code:

def activate(stream, streamname)
writer = StdoutRouter::Writer.new(stream, streamname)
raise if stream.respond_to?(WRITE_WITHOUT_CLI_UI)
stream.singleton_class.send(:alias_method, WRITE_WITHOUT_CLI_UI, :write)
stream.define_singleton_method(:write) do |*args|
writer.write(*args)
end
overriding IO#write for STDOUT and STDERR. This is quietly disabled by any call on IO#reopen, for example: a test calling #capture from https://github.com/rails/rails/blob/0e99d0893b0e98c626a3c7d8972eea22d29c9d25/activesupport/lib/active_support/testing/stream.rb#L23-L38

If the goal of the cli-ui code to be permanent, it needs adjustments. This is true for CRuby and TruffleRuby engines.

More details: truffleruby/truffleruby#3088

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions