Skip to content

Detect the system on windows instead of reading Windows_NT - #7989

Open
denusklo wants to merge 1 commit into
coder:mainfrom
denusklo:windows-os-detection
Open

Detect the system on windows instead of reading Windows_NT#7989
denusklo wants to merge 1 commit into
coder:mainfrom
denusklo:windows-os-detection

Conversation

@denusklo

@denusklo denusklo commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

ci/lib.sh works out OS only when the caller has not set one:

if [[ ! ${OS-} ]]; then OS=$(os); fi

Windows predefines OS as Windows_NT in every process environment, so on a windows shell that test always finds a value, os() is never called, and OS stays Windows_NT for the whole build. Every question the build then asks about the system gets an answer it does not understand: which bin scripts to fix up, whether to build packages, what the release archive is called.

os() already handles this platform (cygwin* | mingw* answers windows), it just never gets the chance. Windows_NT is not a name this build knows, so it is not treated as one a caller chose.

Measured on a windows shell, sourcing the file three ways:

OS unset        -> windows   (was Windows_NT)
OS=Windows_NT   -> windows   (was Windows_NT)
OS=linux        -> linux     (unchanged)

so an explicit choice still wins, which is the point of the check. Nothing changes anywhere else: no other platform sets OS, so the added test is never reached off windows.

This is the "belongs in its own change" fix named in #7987; with it, that job's OS: windows env line becomes redundant rather than necessary.

ci/lib.sh works out OS only when the caller has not set one:

    if [[ ! ${OS-} ]]; then OS=$(os); fi

Windows predefines OS as Windows_NT in every process environment, so on a
windows shell that test always finds a value, os() is never called, and OS
stays Windows_NT for the whole build. Every question the build then asks about
the system gets an answer it does not understand: which bin scripts to fix up,
whether to build packages, what the release archive is called.

os() already handles this platform -- `cygwin* | mingw*` answers windows -- it
just never gets the chance. Windows_NT is not a name this build knows, so it is
not treated as one a caller chose.

Measured on a windows shell, sourcing the file three ways:

    OS unset            -> windows     (was Windows_NT)
    OS=Windows_NT       -> windows     (was Windows_NT)
    OS=linux            -> linux       (unchanged)

so an explicit choice still wins, which is the point of the check. Nothing
changes anywhere else: no other platform sets OS, so the added test is never
reached off windows.
@denusklo
denusklo requested a review from a team as a code owner September 6, 2026 03:46
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

Successfully merging this pull request may close these issues.

1 participant