-
-
Notifications
You must be signed in to change notification settings - Fork 479
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
System.IO.IOException : The handle is invalid - GitHub Actions, Windows #151
Comments
Console.Clear() won't work in places like GitHub actions on a Windows machine, since there isn't an actual console handle to clear and will throw. AnsiConsole.Clear will use ANSI escape sequences to clear the screen, however, not sure if this is supported on GitHub and is probably why you see strange output there. I think your best approach here is to try to detect whether or not running in an non-interactive environment and not run the clear call and animations at all. |
hmm making the tests in this repo pass is relatively easy, but my real issue here is that I'm using this code as part of a NuGet package. If I use Can you think of any way around it? |
Environment.Interactive in combination with the environment variables CI servers define should be enough. |
hmm that's the key, I was missing the point by using the environment variables at compile time rather than at runtime. |
* Use [`Spectre.Console`](https://github.com/spectresystems/spectre.console). * Avoid issues with `Console.Clear()` by checking `Environment.UserInteractive` (spectreconsole/spectre.console#151) and `Console.IsOutputRedirected` ([SO](https://stackoverflow.com/questions/31692714/the-handle-is-invalid-exception-in-visual-studio-2015-test-runner)). No special CI server environment variable will be used for now, but this may need to change in the future if issues are detected (hint for future me: revert d2e4691). * Remove redundant tests.
We just hit the same problem, when running spectre output in a gitlab runner. Maybe this could be patched/tested in spectre library directly ? so that programs would run safely whether they are running in hostile environments or not. it feels wrongs to throw IOException just because output is redirected.. |
I'm using
spectre.console
in a library (this file) and I have a test project that runs simple tests over it.Everything works like a charm locally in both Windows and Linux but I have a CI pipeline configured using GitHub Actions, and tests are failing there in
windows-latest
agents.This is the failed run. I also tried using
pwsh
as shell, but same result.From what I understand, it's failing when invoking
Console.Clear();
, which I do before rendering a table:PD:
I'm trying to use
Console.Clear()
because usingAnsiConsole.Console.Clear()
works for the animation of the table rows being populated, but floodsstdout
with partial tables when scrolling up after the program is run.Am I missing a better way of doing it?
Final result (it can be tested in this project):
But when scrolling up:
The text was updated successfully, but these errors were encountered: