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

ReadLine.Read is not working in MingW64 #55

Open
signityvivek opened this issue Aug 20, 2019 · 2 comments
Open

ReadLine.Read is not working in MingW64 #55

signityvivek opened this issue Aug 20, 2019 · 2 comments

Comments

@signityvivek
Copy link

signityvivek commented Aug 20, 2019

I tried to use the our tool on Windows 7 system in a MINGW64 terminal (that is installed when I installed Git client to access github).

Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
   at System.ConsolePal.ReadKey(Boolean intercept)
   at System.ReadLine.GetText(KeyHandler keyHandler)
   at System.ReadLine.Read(String prompt, String default)
   at Campaign.Program.RunAddAndReturnExitCode(Options options)

A little googling efforts directed me to run it on the default command prompt and it worked like a charm.

Please guide, if there is any configuration required for the same. Thanks

@webmaster442
Copy link

MinGW64's MinTTTY is a TTY emulator. It doesn't support Windows console API's out of the box. You need to run your program wrapped in winpty. Example:

winpty yourexe.exe

@Latency
Copy link

Latency commented Apr 16, 2020

The console emulators will vary across platforms. We will NOT support emulation related issues.

This API uses Console.ReadKey() for its internals which essentially does what Console.Read() does anyway minus a few things windows platform specific. These are from the .NET framework and should be compatible where supported versions of the .NET run-times exist.

You can try using the API within a project targeting .NET Core and run it from the console. This should be universal across platforms. Let me know your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants