shellprogressbar icon indicating copy to clipboard operation
shellprogressbar copied to clipboard

Crashes in git bash

Open andrejohansson opened this issue 7 years ago • 8 comments

Maybe its expected since it´s not written any support, but it could be good to know that it doesnt work in git bash on windows, it fails: Unhandled Exception: System.IO.IOException: The handle is invalid.

Splendid lib otherwise :-)

andrejohansson avatar Apr 18 '18 20:04 andrejohansson

I have the same issue. At least I'm not alone :) Does @Mpdreamz plan to include Git Bash for Windows support in the future?

theamazingfedex avatar May 03 '18 22:05 theamazingfedex

What runtime are you using?

I tested this with .NET Core 2.1.0 and it does crash. I don't think this can be fixed in this library though. I think it needs to be fixed in dotnet/corefx. The problem is that System.Console is trying to use Windows APIs on a unix terminal emulator.

Here is the full stack trace for reference.

$ dotnet run -p src/ShellProgressBar.Example/

Unhandled Exception: System.IO.IOException: The handle is invalid
   at System.ConsolePal.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
   at System.ConsolePal.Clear()
   at System.Console.Clear()
   at ShellProgressBar.Example.Program.RunTestCases(CancellationToken token) in C:\Users\david\Documents\GitHub\shellprogressbar\src\ShellProgressBar.Example\Program.cs:line 95
   at ShellProgressBar.Example.Program.MainAsync(String[] args, CancellationToken token) in C:\Users\david\Documents\GitHub\shellprogressbar\src\ShellProgressBar.Example\Program.cs:line 57
   at ShellProgressBar.Example.Program.Main(String[] args) in C:\Users\david\Documents\GitHub\shellprogressbar\src\ShellProgressBar.Example\Program.cs:line 48

I rarely use windows, so I'm not interested in perusing a fix here, but I think it should be possible for System.Console to try to detect if it is running on a non-windows terminal and try to use System.ConsolePal.Unix instead.

dlech avatar Jul 31 '18 18:07 dlech

I'm seeing this same error while using the Powershell terminal in VS Code. Does that change the assessment of this issue?

jakehockey10 avatar Aug 05 '18 20:08 jakehockey10

Please try: https://www.nuget.org/packages/ShellProgressBar/4.1.1 it works for me in the Bash on Windows terminal.

Mpdreamz avatar Aug 15 '18 17:08 Mpdreamz

@Mpdreamz, this issue still occurs when using Visual Studio Code. Tested with 4.1.1.

jamesrom avatar Aug 22 '18 22:08 jamesrom

@jamesrom what operation system do you use?

Mpdreamz avatar Aug 23 '18 08:08 Mpdreamz

@Mpdreamz, VS Code on Windows 10.

jamesrom avatar Aug 24 '18 04:08 jamesrom

I was running into this issue with Version 5.0.0. Turns out that it was an issue in Visual Studio Code and its built in terminal. See: https://github.com/OmniSharp/omnisharp-vscode/issues/2336

Using 'externalTerminal' in Visual Studio Code launch settings resolved this for me.

"configurations": [ { "name": ".NET Core Launch (console)", "type": "coreclr", "request": "launch", ... "console": "externalTerminal" },

NOTE: I don't know how to stop github collapsing code blocks.

sakennedy avatar Mar 25 '20 07:03 sakennedy