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

clearscreen::clear() returns an error on windows 7 #5

Closed
DaTa- opened this issue Dec 2, 2021 · 1 comment
Closed

clearscreen::clear() returns an error on windows 7 #5

DaTa- opened this issue Dec 2, 2021 · 1 comment

Comments

@DaTa-
Copy link

DaTa- commented Dec 2, 2021

Code to reproduce

main.rs

fn main() {
    clearscreen::clear().unwrap();
}

Cargo.toml

[dependencies]
clearscreen = { git = "https://github.com/watchexec/clearscreen", rev = "3e1b4254f881c03b0d290a4066fc38265f2ac064" }

The error

←[H←[2J←[3Jthread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 87, kind: InvalidInput, message: "The parameter is incorrect." })', src\main.rs:2:26

Doesn't matter if launch from VSCode console, cmd or powershell.

Faulty code, according to debugger: win::is_windows_10 returns true while the platform is windows 7. This is because the logic inside the function expects pwsh_package_management to be indicator of windows 10, but it wasn't in my situation. I have no idea when and what software installed this package during windows lifetime. This caused further code to execute SetConsoleMode on stdout with flag ENABLE_VIRTUAL_TERMINAL_PROCESSING, which is absent on platforms below windows 10 build number 10586 according to this comment on stackoverflow. As a debugging measure, removing pwsh_package_management check gets rid of the error on all tested terminals.

Additional information

c:\>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 7 Ultimate
OS Version:                6.1.7601 Service Pack 1 Build 7601

c:\>powershell.exe -Command Get-Command -Module PackageManagement

c:\>echo %ERRORLEVEL%
0
@passcod passcod closed this as completed in e4f46d6 Dec 2, 2021
@passcod
Copy link
Member

passcod commented Dec 2, 2021

Thanks for this detailed report! Fix out soon in 1.0.9

passcod added a commit that referenced this issue Dec 2, 2021
Fixes #5

Windows 7 Powershell at least as of 6.1.7601 supports the tested
functionality, making the test useless for checking support. Removing
this check completely will rely more on the ability to set the bit as a
check for setting the bit; that's already acknowledged in the docs so 👍
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

2 participants