Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadConsoleInputW failed after upgrade to jansi 2.3.2 #1369

Closed
auricgoldfinger opened this issue Apr 30, 2021 · 4 comments · Fixed by #1371
Closed

ReadConsoleInputW failed after upgrade to jansi 2.3.2 #1369

auricgoldfinger opened this issue Apr 30, 2021 · 4 comments · Fixed by #1371
Labels
theme: shell An issue or change related to interactive (JLine) applications type: dependency 📚
Milestone

Comments

@auricgoldfinger
Copy link
Contributor

auricgoldfinger commented Apr 30, 2021

Today, we upgraded some libraries in our picocli tool. Amongst them, there was a serious upgrade from Jansi 1.8 to 2.3.2.
Suddenly, picocli-shell-jline3 crashed on us. I tried to run the example and it suffers from exactely the same issue:

WARNING: Error in WindowsStreamPump
java.io.IOException: ReadConsoleInputW failed: The specified procedure could not be found.
        at org.fusesource.jansi.internal.Kernel32.readConsoleInputHelper(Kernel32.java:530)
        at org.jline.terminal.impl.jansi.win.JansiWinSysTerminal.processConsoleInput(JansiWinSysTerminal.java:126)
        at org.jline.terminal.impl.AbstractWindowsTerminal.pump(AbstractWindowsTerminal.java:460)
        at java.base/java.lang.Thread.run(Thread.java:831)

.. then the console crashes.

In our tool, after AnsiConsole.systemInstall(), we also do Ansi.setEnabled(true);. Then this error is thrown:

WARNING: Error in WindowsStreamPump
java.io.IOException: ReadConsoleInputW failed: Incorrect function.
        at org.fusesource.jansi.internal.Kernel32.readConsoleInputHelper(Kernel32.java:530)
        at org.jline.terminal.impl.jansi.win.JansiWinSysTerminal.processConsoleInput(JansiWinSysTerminal.java:126)
        at org.jline.terminal.impl.AbstractWindowsTerminal.pump(AbstractWindowsTerminal.java:460)
        at java.base/java.lang.Thread.run(Thread.java:831)

Important to note, we're using Git Bash in ConEmu. I had the latest stable version running, some older version, so I upgraded it as well (to Build 210422) and that didn't solve the problem.
When I run the command (both the example as well as our own tool) in Windows Terminal, it works fine.

Does anyone have any idea how to solve this?

@remkop
Copy link
Owner

remkop commented May 2, 2021

This looks like a Jansi issue. Have you raised this in the Jansi issue tracker?

@auricgoldfinger
Copy link
Contributor Author

When I disable Jansi completely, the problem is that a dumb terminal is created in stead of a real one. Then everying crashes in a stackoverflow.

I was able to solve it by forcing jline to be the latest version as well in the gradle build:

constraints {
    implementation("org.jline:jline") {
        version{
            require "3.19.0"
        }
    }
}

... then everything works fine in Git Bash and ConEmu...

It's broken again in Windows Terminal but I can live with that. It used to be broken anyway. Terminals on Windows, it stays a complex story

@remkop
Copy link
Owner

remkop commented May 2, 2021

Is there something that can be done in picocli to help with this?
Maybe a note in the picocli-shell-jline3 README?
Would you be interested in providing a pull request for this?

@auricgoldfinger
Copy link
Contributor Author

Done! It's just a simple upgrade of the jline3 version :-)

@remkop remkop closed this as completed in 6e90bea May 5, 2021
@remkop remkop linked a pull request May 5, 2021 that will close this issue
@remkop remkop added this to the 4.6.2 milestone May 5, 2021
@remkop remkop added type: dependency 📚 theme: shell An issue or change related to interactive (JLine) applications labels May 5, 2021
remkop added a commit that referenced this issue May 5, 2021
MarkoMackic pushed a commit to MarkoMackic/picocli that referenced this issue Oct 17, 2021
MarkoMackic pushed a commit to MarkoMackic/picocli that referenced this issue Oct 17, 2021
…"ReadConsoleInputW failed: Incorrect function" error
MarkoMackic added a commit to MarkoMackic/picocli that referenced this issue Oct 17, 2021
…o avoid "ReadConsoleInputW failed: Incorrect function" error"

This reverts commit 24ef290.
MarkoMackic added a commit to MarkoMackic/picocli that referenced this issue Oct 17, 2021
MarkoMackic added a commit to MarkoMackic/picocli that referenced this issue Oct 17, 2021
…o avoid "ReadConsoleInputW failed: Incorrect function" error"

This reverts commit 24ef290.
MarkoMackic added a commit to MarkoMackic/picocli that referenced this issue Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: shell An issue or change related to interactive (JLine) applications type: dependency 📚
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants