Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8302160

JDK 20+30 breaks external JLine usage with Error executing 'tty': not a tty (java.io.IOException)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P3
    • None
    • 20
    • core-libs
    • None
    • 20

    Description

      I found a regression between JDK 20+26 and JDK 20+30.
      Before, these test work fine, after they fail like:
      ```
      Couldn't initialize readline (java.lang.UnsupportedOperationException)
      from org.truffleruby.stdlib.readline.ConsoleHolder.<init>(ConsoleHolder.java:142)
      from org.truffleruby.stdlib.readline.ConsoleHolder.create(ConsoleHolder.java:89)
      from org.truffleruby.RubyContext.getConsoleHolder(RubyContext.java:677)
      from org.truffleruby.stdlib.readline.ReadlineNodes$BasicWordBreakCharactersNode.basicWordBreakCharacters(ReadlineNodes.java:69)
      from org.truffleruby.stdlib.readline.ReadlineNodesFactory$BasicWordBreakCharactersNodeFactory$BasicWordBreakCharactersNodeGen.execute(ReadlineNodesFactory.java:105)
      from org.truffleruby.language.RubyCoreMethodRootNode.execute(RubyCoreMethodRootNode.java:58)
      Caused by:
      Not a tty (java.io.IOException)
      from org.graalvm.shadowed.org.jline.terminal.impl.ExecPty.current(ExecPty.java:44)
      from org.truffleruby.stdlib.readline.ConsoleHolder.<init>(ConsoleHolder.java:127)
      from org.truffleruby.stdlib.readline.ConsoleHolder.create(ConsoleHolder.java:89)
      from org.truffleruby.RubyContext.getConsoleHolder(RubyContext.java:677)
      from org.truffleruby.stdlib.readline.ReadlineNodes$BasicWordBreakCharactersNode.basicWordBreakCharacters(ReadlineNodes.java:69)
      from org.truffleruby.stdlib.readline.ReadlineNodesFactory$BasicWordBreakCharactersNodeFactory$BasicWordBreakCharactersNodeGen.execute(ReadlineNodesFactory.java:105)
      from org.truffleruby.language.RubyCoreMethodRootNode.execute(RubyCoreMethodRootNode.java:58)
      Caused by:
      Error executing 'tty': not a tty (java.io.IOException)
      from org.graalvm.shadowed.org.jline.utils.ExecHelper.exec(ExecHelper.java:42)
      from org.graalvm.shadowed.org.jline.terminal.impl.ExecPty.current(ExecPty.java:41)
      from org.truffleruby.stdlib.readline.ConsoleHolder.<init>(ConsoleHolder.java:127)
      from org.truffleruby.stdlib.readline.ConsoleHolder.create(ConsoleHolder.java:89)
      from org.truffleruby.RubyContext.getConsoleHolder(RubyContext.java:677)
      from org.truffleruby.stdlib.readline.ReadlineNodes$BasicWordBreakCharactersNode.basicWordBreakCharacters(ReadlineNodes.java:69)
      from org.truffleruby.stdlib.readline.ReadlineNodesFactory$BasicWordBreakCharactersNodeFactory$BasicWordBreakCharactersNodeGen.execute(ReadlineNodesFactory.java:105)
      from org.truffleruby.language.RubyCoreMethodRootNode.execute(RubyCoreMethodRootNode.java:58)
      ```

      I would guess it's related to the recent addition of the internal JLine.

      That error seems to mean the `tty` command had output `not a tty`.
      Locally on linux-amd64, I get that output when stdin is /dev/null: `tty </dev/null`, but not if stdout and/or stderr are redirected (with original stdin).

      I'm not sure how but it seems the new internal JLine messes up existing usages of JLine.
      Maybe there can only be a single system terminal, or there is some side effect of changing stdin/stdout/stderr when calling `System.console() != null` (to find out if a TTY)?

      Given the various issues with the internal JLine (e.g. JDK-8299689),
      maybe it is worth reconsidering whether it's a good idea to add an internal copy of JLine in the JDK?

      You can reproduce with the instructions to build TruffleRuby at https://github.com/oracle/truffleruby/blob/master/doc/contributor/workflow.md
      And then:
      ```
      bin/jt test spec/ruby/library/readline
      ```

      This works fine on JDK 20+26, but fails on JDK 20+30.

      It happens on at least linux-amd64, darwin-amd64 and darwin-aarch64.

      Attachments

        Issue Links

          Activity

            People

              naoto Naoto Sato
              bdaloze Benoit Daloze
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: