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

thread 'main' panicked at 'Initial console color not set' #10

Closed
pozemka opened this issue Jun 3, 2020 · 8 comments
Closed

thread 'main' panicked at 'Initial console color not set' #10

pozemka opened this issue Jun 3, 2020 · 8 comments

Comments

@pozemka
Copy link

pozemka commented Jun 3, 2020

When launched pwatch from cmd.exe console I had this error:

It is Windows 7, barely updated, and with default settings.

C:\stuff\bin>pwatch.exe QueryTtest

thread 'main' panicked at 'Initial console color not set', C:\Users\vvm\.cargo\r
egistry\src\github.com-1ecc6299db9ec823\crossterm-0.17.4\src\style\sys\windows.r
s:97:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

C:\stuff\bin>set RUST_BACKTRACE=1

C:\stuff\bin>pwatch.exe QueryTtest

thread 'main' panicked at 'Initial console color not set', C:\Users\vvm\.cargo\r
egistry\src\github.com-1ecc6299db9ec823\crossterm-0.17.4\src\style\sys\windows.r
s:97:5
stack backtrace:
   0: backtrace::backtrace::dbghelp::trace
             at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc629
9db9ec823\backtrace-0.3.44\src\backtrace/dbghelp.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc629
9db9ec823\backtrace-0.3.44\src\backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src\libstd\sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Displa
y>::fmt
             at src\libstd\sys_common/backtrace.rs:59
   4: core::fmt::write
             at src\libcore\fmt/mod.rs:1063
   5: std::io::Write::write_fmt
             at src\libstd\io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src\libstd\sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src\libstd\sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src\libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src\libstd/panicking.rs:224
  10: std::panicking::rust_panic_with_hook
             at src\libstd/panicking.rs:470
  11: rust_begin_unwind
             at src\libstd/panicking.rs:378
  12: core::panicking::panic_fmt
             at src\libcore/panicking.rs:85
  13: core::option::expect_failed
             at src\libcore/option.rs:1203
  14: crossterm::style::sys::windows::original_console_color
  15: crossterm::style::sys::windows::reset
  16: <crossterm::style::ResetColor as crossterm::command::Command>::execute_win
api
  17: pwatch::main
  18: std::rt::lang_start::{{closure}}
  19: std::rt::lang_start_internal::{{closure}}
             at src\libstd/rt.rs:52
  20: std::panicking::try::do_call
             at src\libstd/panicking.rs:303
  21: __rust_maybe_catch_panic
             at src\libpanic_unwind/lib.rs:86
  22: std::panicking::try
             at src\libstd/panicking.rs:281
  23: std::panic::catch_unwind
             at src\libstd/panic.rs:394
  24: std::rt::lang_start_internal
             at src\libstd/rt.rs:51
  25: main
  26: __tmainCRTStartup
             at C:/crossdev/src/mingw-w64-v4-git/mingw-w64-crt/crt/crtexe.c:332
  27: mainCRTStartup
             at C:/crossdev/src/mingw-w64-v4-git/mingw-w64-crt/crt/crtexe.c:212
  28: unit_addrs_search
  29: unit_addrs_search
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose bac
ktrace.

C:\stuff\bin>
@VladimirMarkelov
Copy link
Owner

I wonder what happens if the binary built on the same machine is launched. Will it work? It looks like an exception from underlying library that reads:

Tested terminals (Windows CMD):
    Windows 10 (Pro)
    Windows 8.1 (N)

Though it states This crate supports all UNIX terminals and Windows terminals down to Windows 7; however, not all of the terminals have been tested, it seems that Windows 7 CMD is not tested thoroughly. I tried on Windows 10 CMD - it obviously works as I has built the binary on this machine.

@VladimirMarkelov
Copy link
Owner

Panic is fixed but it was not enough for the app to be run on Windows 7

@pozemka
Copy link
Author

pozemka commented Jun 8, 2020

That's unfortunate but understandable.
The 0.3.1 release do not crash on Win 7 but output is barely readable. Same results when using conemu instead of cmd:

изображение

@VladimirMarkelov
Copy link
Owner

It looks like a used terminal library detects that terminal in Windows 7 does not support ANSI codes and removes all of them from output (including Goto ones) that results in the picture above.

@pozemka
Copy link
Author

pozemka commented Jun 10, 2020

Are you using crossterm as underlying library?
Probably it is worth to report bug there? It seems author fixing some bugs related to old APIs: crossterm-rs/crossterm#38

Or probably you can switch to "WinAPI back-end" for Windows 7? Not sure what it is but it is mentioned there

@VladimirMarkelov
Copy link
Owner

From crossterm-rs/crossterm#445 I understand that terminal app for Windows console that does not support queueing requires using different slower method. Besides a lot of rewriting, it can also mean double work for screenshotting: now I can implement a screenshotter that is compatible with the existing Writer trait, if I switch to "Windows specific" calls that do not support Writer interface I likely have to do double work by duplicating the calls for screenshotter.

@sigmaSd
Copy link

sigmaSd commented Jul 20, 2020

Hi, this is fixed in crossterm 0.17.8 (to be released soon).

@VladimirMarkelov
Copy link
Owner

Hi, this is fixed in crossterm 0.17.8 (to be released soon).

Thank you for heads up! Looking forward to the new version.

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