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

Text echoes after using backtick on Windows 11 command prompt/powershell #676

Open
andrewngo opened this issue Apr 10, 2024 · 3 comments
Open
Labels
bug Something isn't working Windows

Comments

@andrewngo
Copy link

andrewngo commented Apr 10, 2024

Description

What are your expected behavior and actual behavior of your environment?

After using a backtick command, Readline behaves strangely, sometimes it echoes all input and sometimes it doesn't show my input at all.

older version of irb/reline

irb(main):001:0> `choco -v`
=> "2.2.0\n"
irb(main):002:0> irb(main):002:0> p█████████      irb(main):002:0> pu       ppppppppirb(main):002:0> put      ppirb(main):002:0> puts  irb(main):002:0> puts irb(main):002:0> puts 'irb(main):002:0' puts 'hirb(main):002:0' puts 'heirb(main):002:0' puts 'helirb(main):002:0' puts 'hellirb(main):002:0' puts 'helloirb(main):002:0' puts 'hello'hello
=> nil
irb(main):003:0> irb(main):003:0> eeeeeeeeeeeeeirb(main):003:0> ex        eeeeirb(main):003:0> exi  eeirb(main):003:0> exitee

other times (latest irb/reline) it doesn't show my input until I press 'enter'

irb(main):001> `choco -v`
=> "2.2.0\n"
i▀irb(main):002> puts 'hi'
hi
=> nil
i▀irb(main):003> exit

Terminal Emulator

What's your terminal emulator?
Windows 11 Powershell/Terminal

ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e)

*** LOCAL GEMS ***
irb (1.12.0)
reline (0.5.1)

@andrewngo
Copy link
Author

andrewngo commented Apr 10, 2024

Adding these gems seem to workaround the issue for me for now

gem 'readline'
gem 'readline-ext'

edit: these gems do cause copy/paste to behave oddly so it's more of a trade-off than workaround now

@ima1zumi ima1zumi added Windows bug Something isn't working labels Apr 11, 2024
@tompng
Copy link
Member

tompng commented Apr 11, 2024

For investigation, can you check these value before and after problem occurs?

Reline::IOGage.get_screen_size
Reline::IOGage.get_console_screen_buffer_info
STDIN.winsize

Does it happens with specific command or any command?

@andrewngo
Copy link
Author

I don't see the issue with commands like echo "hello", but other apps like ruby -v, chromedriver -v or choco are all issues

irb(main):002> Reline::IOGate.get_screen_size
=> [30, 120]
irb(main):003> Reline::IOGate.get_console_screen_buffer_info
=> "x\x00\x1E\x00\x00\x00\x1D\x00\a\x00\x00\x00\x00\x00w\x00\x1D\x00x\x00\x1E\x00"
irb(main):004> STDIN.winsize
(irb):4:in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)
        from (irb):4:in `<main>'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/irb-1.12.0/exe/irb:9:in `<top (required)>'
        from C:/Ruby31-x64/bin/irb:32:in `load'
        from C:/Ruby31-x64/bin/irb:32:in `<main>'

after

irb(main):006> `chromedriver -v`
=> "ChromeDriver 123.0.6312.122 (31f8248cdd90acbac59f700b603fed0b5967ca50-refs/branch-heads/6312@{#824})\n"
iirb(main):007> Reline::IOGate.get_screen_size
=>
[1,
 1]
iirb(main):008> Reline::IOGate.get_console_screen_buffer_info
=> nil
i▀irb(main):009> STDIN.winsize
(irb):9:in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)
        from (irb):9:in `<main>'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/irb-1.12.0/exe/irb:9:in `<top (required)>'
        from C:/Ruby31-x64/bin/irb:32:in `load'
        from C:/Ruby31-x64/bin/irb:32:in `<main>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Windows
Development

No branches or pull requests

3 participants