Skip to content

Don't enable test mode by TERM=dumb #660

Open

Description

@tompng

Problem

In IRB's test code, TERM=dumb triggers Reline's test mode io Reline::GeneralIO (unlike the name, this is not a general io)

In practice, TERM=dumb seems to be used in real world. (example: pry/pry#2303)
It will unintentionally enables Reline's test mode and cause problems.

I think Reline should not use TERM=dumb to enable test mode. We need another way to enable it, or remove this test mode after fixing IRB's test not to depend on this.

Activity

  1. changed the title [-]Enable test mode not by TERM=dumb[/-] [+]Don't enable test mode by TERM=dumb[/+] on Mar 23, 2024
  2. st0012 commented on Mar 23, 2024

    @st0012
    Member

    I haven't looked much into the issue yet, but we need to be very cautious about this change because many projects, like Rails and debug, use TERM=dumb to turn on the Reline test mode. If we did decide to implement this change, let's make sure we roll it out gradually (e.g. supporting both TERM=dumb and the alternative for a while) so we have time to help those projects updating their tests.

  3. dgutov commented on Mar 23, 2024

    @dgutov

    FWIW, if we're talking about Reline inside Emacs, then removing special handling for TERM=dumb is not enough: if I just change those checks, that brings back the ▽ problem.

  4. tompng commented on Mar 24, 2024

    @tompng
    MemberAuthor

    If we're doing this, we also need to disable ▽ and "\e[6n" (Query Cursor Position) if TERM=dumb.

  5. eregon commented on Mar 7, 2026

    @eregon
    Member

    like Rails and debug, use TERM=dumb to turn on the Reline test mode.

    I'm surprised by this, does anyone using Rails or the debug gem really want the Reline test mode?
    It outputs a lot of extra output which seems unusable except maybe when debugging Reline itself:

    $ echo 'my input' > in
    $ TERM=dumb ruby -rreadline -e 'p Readline; p [STDIN,STDOUT,STDERR].map(&:tty?); p Readline.readline("> ", true)' < in |& ruby -e 'p STDIN.read' 
    "Reline\n[false, false, false]\n> > mmymy my imy inmy inpmy inpumy input> my input\r\n\"my input\"\n"
    

    (context: #886)

  6. st0012 commented on Mar 9, 2026

    @st0012
    Member

    It's used in those projects to run integration tests that can verify the console's outupt. Not by their users.

  7. eregon commented on Mar 9, 2026

    @eregon
    Member

    Would you have an example?
    I find it unlikely that some test would check e.g. that my input results in mmymy my imy inmy inpmy inpumy input or so.

    I'd expect tests would use TERM=dumb to avoid extra escape sequences from Reline (#886), but then (non-reline-internal) tests would also expect no extra prints like mmymy my imy inmy inpmy inpumy input.

  8. eregon commented on Mar 9, 2026

    @eregon
    Member

    Reline test mode

    What does that do?
    I think it's most people expectation that TERM=dumb means no extra escape sequences, and also that it behaves like a dumb terminal so e.g. echo'es the input as-is or with minimal changes, and without what looks like reline debugging output or so.

    IOW, I doubt that disabling the mmymy my imy inmy inpmy inpumy input debugging would break any non-reline-internal test.
    And that the original issue seems worth solving and seems not so likely to break anything.

  9. st0012 commented on Mar 9, 2026

    @st0012
    Member

    https://github.com/rails/rails/blob/7ff005d9416388f0fa6d89895c4c560c13717164/railties/test/engine/commands_test.rb#L40

    The goal is to just capture input for testing. But unfortunately we have to print every character too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions