Skip to content

Prefer the .cmd sibling when Windows resolves an extensionless npm shim - #9238

Merged
danielhanchen merged 11 commits into
unslothai:mainfrom
lonexreb:fix/windows-extensionless-shim
Aug 25, 2026
Merged

danielhanchen merged 11 commits into
unslothai:mainfrom
lonexreb:fix/windows-extensionless-shim

Conversation

@lonexreb

@lonexreb lonexreb commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What

On Windows, unsloth start codex / unsloth start pi could die in CreateProcess with WinError 193 when shutil.which() resolved npm/pnpm's extensionless POSIX shim ahead of the .cmd sibling. Fixes #9167.

How

_prefer_windows_cmd_sibling(): when on Windows, the resolved path does not carry a Windows-executable suffix, and the file opens with a shebang (what an unlaunchable npm/pnpm POSIX shim always is), substitute a sibling .cmd / .CMD if one exists. A PE binary — which CreateProcess can run regardless of its name — keeps priority over any stale wrapper beside it.

Applied at the resolver layer, not just the launch path (per review — thanks @mahiatlinux):

  • _which_with_install_dirs — covers the Claude/Codex/OpenCode version and capability probes that spawn the result directly, including under --no-launch
  • _npm_executable — covers agent installation via PowerShell
  • codex_subagent_mcp.py / claude_subagent_mcp.py — the MCP bridges that call shutil.which + Popen themselves
  • _resolved_launch_command — covers _launch's raw shutil.which resolver

Notes on the guard:

  • Matched on not-a-Windows-suffix rather than no-suffix, so a dotted bin name (cmd-shim writes foo.bar.cmd next to foo.bar) is rescued too.
  • Probes .cmd then .CMD (case-sensitive volumes) only — neither npm's cmd-shim nor pnpm's writer produces a .bat sibling.
  • OSError during the peek (directory, unreadable, deleted between resolve and open) falls through to the original path.

Reach

In the same-directory layout #9167 reports, shutil.which offers the bare name first on CPython 3.12.0 specifically (3.12.1+ move it last; most other versions never offer it). The rescue also applies when PATH ordering hands back an extensionless shim from an earlier directory, and is a no-op everywhere else.

Tests

Eight tests around _resolved_launch_command / _prefer_windows_cmd_sibling / _which_with_install_dirs: sibling preference, dotted bin name, shebang gate (PE + stale sibling untouched), no-sibling pass-through (mutation-verified: replacing sibling.is_file() with True fails it), directory-fixture OSError suppression, None-safety, POSIX no-op, and resolver-layer application. Full unsloth_cli/tests/test_start.py: 508 pass (500 at merge base). Ruff clean, kwarg-spacing formatter applied.

lonexreb and others added 2 commits August 18, 2026 17:48
shutil.which can hand back npm/pnpm's extensionless POSIX shim ahead of the
.cmd sibling that Windows can actually execute, so unsloth start codex/pi
died in CreateProcess with WinError 193. Resolve the sibling first, then let
the existing cmd-shim parser take over.

Fixes unslothai#9167
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed this hits the path in unsloth_cli/commands/start.py where _resolved_launch_command only enters the shim parser for .cmd/.bat, so an extensionless npm shim still reaches CreateProcess. Will get this reviewed.

CreateProcess can run a PE binary regardless of its name, so a resolved
real executable must keep priority over a stale .cmd wrapper beside it.
Substitute the sibling only when the resolved file opens with a shebang,
which is what an unlaunchable npm/pnpm POSIX shim always does.
@mahiatlinux

Copy link
Copy Markdown
Contributor

unsloth_cli/commands/start.py:3521 — the rescue sits below the layer where the misresolution happens

_resolved_launch_command is reached only from _launch (line 3619). The same shutil.which result is spawned directly by four other call sites, all on the commands this PR is fixing, and none of them go through it.

_which_with_install_dirs (3205) calls shutil.which(name) at 3214 with the default mode, byte for byte what _launch passes as its resolver at 3596. So whatever hands _launch the extensionless shim hands these the same path:

  • start.py:2775, the OpenCode provider-filter probe. except Exception as exc: _fail(...) at 2782 turns WinError 193 into a hard exit: Could not inspect OpenCode provider filters: [WinError 193] %1 is not a valid Win32 application. It runs at 4676, after _connect has already started the server and loaded the model, and _fail fires before _run, so the atexit backstop tears the loaded server down. unsloth start opencode --as-subagent is unusable on the machine in Windows: unsloth start codex/pi can fail with WinError 193 when npm/pnpm extensionless shim is resolved before .cmd #9167 with this merged.
  • start.py:2448, _codex_supports_model_catalog. except Exception: return False at 2455 gates write_codex_config at 2511, so model_catalog_json is dropped and model-catalog.json is never written. This is the unsloth start codex path from the issue: the launch now succeeds while Codex is configured without _CODEX_FALLBACK_PROMPT, supports_parallel_tool_calls, and the reasoning pins. Note the asymmetry with 2445, where an absent codex returns True - a box that hits 193 is treated worse than a box with no codex at all.
  • start.py:2371, _claude_version. Returns (0,), so _claude_flags (2384) returns [] and --settings is dropped. That overlay is the only source of availableModels; _claude_local_env does not supply it.
  • start.py:385, _opencode_supports_native_auto. Returns False, so --yolo falls back to the inline permission block instead of native --auto, which by the comment at 4140-4143 overrides a project's explicit deny rules rather than preserving them.

All four also run under --no-launch, where _resolved_launch_command is never called at all.

The same resolution feeds _npm_executable (3241), whose result goes into "& " + ... for PowerShell at 3286, so installing a missing agent fails the same way. unsloth_cli/codex_subagent_mcp.py:85 and unsloth_cli/claude_subagent_mcp.py:147 call shutil.which and Popen the result directly, bypassing this function entirely.

Extract the block into a None-safe helper and call it from the resolver as well, which is what the issue suggested:

def _prefer_windows_cmd_sibling(executable):
    """Prefer the sibling .cmd when Windows resolved an extensionless npm/pnpm shim."""
    if executable is None or os.name != "nt":
        return executable
    ...

then return _prefer_windows_cmd_sibling(shutil.which(name)) at 3214.

unsloth_cli/tests/test_start.py:1721 — the no-sibling test stops at the shebang gate and no longer covers the sibling probe

The fixture is executable.write_bytes(b"MZ"), so _resolved_launch_command returns at the read(2) == b"#!" check on 3539 and never reaches the loop the test is named for. The test passes with the entire production hunk reverted, and it is now a strict subset of keeps_extensionless_pe_binary_over_stale_sibling at 1749: same fixture, plus a sibling that is never consulted.

This coverage existed and was lost in this branch's last commit. At 399789d19, replacing sibling.is_file() with True fails this test. At ab4b05d1a the same mutation leaves the whole file green, because the gate bails first.

Fix is line 1721:

    executable.write_text("#!/bin/sh\n", encoding = "utf-8")

That restores the failure under the mutation and leaves the two tests covering distinct branches.

unsloth_cli/commands/start.py:3537 — nothing covers the OSError suppression

Replacing contextlib.suppress(OSError) with an unguarded block leaves every test passing. It is not a redundant guard: executable is a path shutil.which returned, and a directory at that path, an unreadable file, or a delete between the resolve and the open all raise out of _launch instead of launching. A directory fixture pins it:

    executable = tmp_path / "fake-agent"
    executable.mkdir()
    (tmp_path / "fake-agent.cmd").write_text("@ECHO off\n", encoding = "utf-8")
    assert start._resolved_launch_command(str(executable), ["--flag"]) == [str(executable), "--flag"]

unsloth_cli/commands/start.py:3540 — .bat is not written by either shim writer, and the probe order contradicts the stated rationale

npm's cmd-shim writes exactly three files (lib/index.js, the final Promise.all): to, to + '.cmd', to + '.ps1'. pnpm's @zkochan/cmd-shim@9 pushes {extension: ''}, {extension: CMD_EXTENSION}, {extension: '.ps1'}, and CMD_EXTENSION comes from the cmd-extension package, which reads a .cmd casing out of PATHEXT and defaults to .cmd. Neither writer produces a .bat sibling.

Separately, the description justifies the fall-through as "which is what cmd.exe/PATHEXT resolution would have picked anyway". The default PATHEXT is .COM;.EXE;.BAT;.CMD;..., so .BAT outranks .CMD. With both siblings present this code picks .cmd and cmd.exe would pick .bat, so the claim does not hold in the one case where the two entries can disagree.

Dropping .CMD from the tuple is caught by no test; dropping .bat is caught by no test.

The description describes the branch before its last commit

  • "probe for a sibling .cmd / .CMD / .bat and switch to it if one exists" was true at 399789d19. ab4b05d1a gated the whole thing on the resolved file opening with #!, so an extensionless file with a .cmd sibling that does not start with a shebang is now left alone. The stated rule is unconditional.
  • "Four new tests" - five were added. The one the parenthesised list omits is keeps_extensionless_pe_binary_over_stale_sibling, added by the same commit.
  • "Full unsloth_cli/tests/test_start.py: 504 pass" - 504 is the count at 399789d19. At ab4b05d1a it is 505, against 500 at the merge base.

Reach of the fix is narrower than the description implies

In the layout #9167 reports, with the shim and its .cmd in one directory, shutil.which returns the extensionless file on CPython 3.12.0 only. Lib/shutil.py at v3.12.0:1558 is files = [cmd] + [cmd + ext for ext in pathext] with no reorder. v3.12.1 through v3.12.7 and v3.13.0 keep the bare name in files but move it last within each directory via files.append(files.pop(0)) under the default F_OK|X_OK, so pi.CMD wins. 3.9 through 3.11, 3.12.8 and later, 3.13.1 and later, and 3.14 never offer the bare name at all. Under requires-python = ">=3.9,<3.15" that is one patch release, which is worth saying in the description rather than leaving "shutil.which can hand back the former" to read as universal.

@mahiatlinux mahiatlinux self-assigned this Aug 19, 2026
@mahiatlinux
mahiatlinux self-requested a review August 19, 2026 09:46

@mahiatlinux mahiatlinux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review posted as a comment above.

The rescue lived only in _resolved_launch_command, which _launch alone
reaches. The version and capability probes, npm install resolution, and
the MCP subagent bridges all spawn the same shutil.which result directly,
so an extensionless shim still broke them (and everything under
--no-launch). Extract _prefer_windows_cmd_sibling, apply it in
_which_with_install_dirs, _npm_executable, both subagent bridges, and
keep the _resolved_launch_command call for _launch's raw resolver.

Also per review: drop .bat (neither npm's cmd-shim nor pnpm's writer
produces one), restore the no-sibling test's mutation coverage lost to
the shebang gate, and pin the OSError suppression with a directory
fixture.
@lonexreb

Copy link
Copy Markdown
Contributor Author

@mahiatlinux Thank you for the thorough review — every point was right, addressed in a5f1f06:

  • Resolver layer: extracted _prefer_windows_cmd_sibling() (None-safe, POSIX no-op) and applied it in _which_with_install_dirs — covering the four probe sites and --no-launch — plus _npm_executable (both which() calls) and the two MCP subagent bridges. _resolved_launch_command keeps a call for _launch's raw shutil.which resolver.
  • Lost mutation coverage: the no-sibling test now uses a shebang fixture, so it exercises the probe loop again — verified sibling.is_file() → True fails it at this commit.
  • OSError suppression: pinned with your directory fixture.
  • .bat: dropped — probes .cmd then .CMD only, with the shim-writer facts in the helper's docstring, and the incorrect PATHEXT fall-through claim removed from the description.
  • Description drift + reach: rewritten to describe the shebang-gated behavior, correct test counts, and the CPython 3.12.0 nuance.

508 pass locally (500 at merge base).

unslothai#9167's pnpm dir holds pi.CMD, not pi.cmd. Dropping .CMD from the probe
tuple was caught by no test, so the entry could be removed silently.
Default NTFS matches either casing on the .cmd probe, but a case-sensitive
volume (ReFS, or a directory flagged with fsutil setCaseSensitiveInfo) does
not, and neither does a case-sensitive CI filesystem.
@danielhanchen

Copy link
Copy Markdown
Member

Went through this one carefully since we cannot run Windows on our CI box, and I wanted evidence rather than a code read. Summary: the issue is real, the fix is correct, and I could not find a path it regresses. I pushed one small test on top.

Before and after

Before, on Windows with a Python in the 3.12.0 to 3.12.9 range, unsloth start codex resolves C:\Program Files\nodejs\codex, the extensionless npm POSIX shim, hands it to subprocess.run, and CreateProcess raises OSError: [WinError 193] %1 is not a valid Win32 application. The server itself starts fine, so the failure looks unrelated to the agent launch until you read the traceback. After, the resolver substitutes the codex.cmd sibling, which CreateProcess runs through its documented batch handling, and the existing npm shim parser takes it from there.

Root cause is upstream, not ours

This is CPython gh-109590 / gh-127001. PR #103179 made shutil.which probe the bare name before PATHEXT, so from 3.12.0b1 an extensionless npm shim wins over its own .cmd. It was fixed in 3.12.10 by gh-127035. Two reasons to still carry this fix: our requires-python is >=3.9,<3.15, so every 3.12.0 to 3.12.9 user is in range, and even on a fixed interpreter a PATHEXT containing . reintroduces the bare-name match. On a fixed interpreter with a normal PATHEXT the helper is a no-op, since which already returns the .cmd and the suffix check returns early.

How I verified it

I built a simulator that models the two real behaviours this sits between: shutil.which under both the buggy 3.12 algorithm and the 3.11 / 3.12.10+ algorithm, and CreateProcess, which accepts PE images and .cmd/.bat and rejects everything else with WinError 193. NTFS case-insensitivity is modelled too, with a switch for case-sensitive volumes. The filesystem layouts come from the where.exe and Get-Command output in #9167 verbatim, including the uppercase pi.CMD, so this reproduces the reported failure rather than a hypothetical one.

Same 19 scenarios run against the merge base and the head:

merge base head
scenarios passing 10 / 18 19 / 19

Seven scenarios flip from WinError 193 to a successful launch, and none regress:

Passing identically at both ends, which is the part I cared about most:

  • a real extensionless PE image keeps priority over a stale .cmd beside it
  • .exe and already-.cmd resolutions pass through byte for byte, and the rescue is idempotent
  • a directory, an empty file, or a sibling that is itself a directory all fall through without raising
  • a shebang shim with no sibling still fails, unchanged, since there is nothing to substitute
  • POSIX and WSL never rewrite anything, measured for real on Linux rather than simulated, since os.name is posix there and the helper returns immediately

I also mutation-tested the guards rather than trusting that the tests cover them. Breaking sibling.is_file(), the shebang gate, or the contextlib.suppress(OSError) each turns the suite red.

Compatibility: the helper compiles and behaves correctly on 3.9 through 3.14. Nothing under studio/ is touched, and Studio has its own separate shutil.which call sites, so its GPU and runtime detection are unaffected. Old installs are unaffected too, since this only changes which of two files already on disk gets spawned. I checked the two remaining raw shutil.which calls in the launch path: the one in _wsl_windows_executable is WSL-only and returns early on os.name == "nt", and the one in _install_agent has its result discarded by all six callers, so neither is a gap.

Not covered by any of this: no real Windows host ran a single line of it. The simulation encodes documented behaviour, not observed behaviour, so a confirmation from anyone on Windows with a 3.12.x in the affected range would be worth having.

What I pushed

adcdcaf99 adds one test. @mahiatlinux flagged that dropping .CMD from the probe tuple was caught by no test, and that was still true. On default NTFS the .cmd probe already matches pi.CMD because the volume is case-insensitive, so the entry only carries weight on a case-sensitive volume, meaning ReFS or a directory flagged with fsutil file setCaseSensitiveInfo, and on a case-sensitive CI filesystem. The new test writes only an uppercase sibling and asserts the rescue finds it, which makes removing the entry fail the suite. 506 pass, 3 skipped.

One thing left deliberately alone: if someone has .PS1 in PATHEXT, which can return codex.ps1, the suffix guard skips it, and CreateProcess still fails. That is the status quo rather than a regression, .PS1 is not in the stock PATHEXT, and nobody has reported it, so it seems out of scope here.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: adcdcaf99e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Also correct the docstring's account of when shutil.which returns the bare
name: it is the CPython 3.12.0 to 3.12.9 regression (gh-127001), or a PATHEXT
containing a dot-only entry, not any earlier PATH entry.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen and others added 2 commits August 24, 2026 09:26
Both bridges resolved an executable and handed it straight to Popen. On
Windows that can be a .cmd, which CreateProcess runs through cmd.exe, and
cmd.exe treats CR/LF inside %* as command separators. The Codex prompt and
Claude's --append-system-prompt always span lines, so the child could receive
a truncated prompt or execute prompt text as shell input.

This predates the .cmd rescue: shutil.which already returned the .cmd on every
Python outside the 3.12.0 to 3.12.9 window. The rescue makes it reachable on
that window too, so route both spawns through _resolved_launch_command, which
resolves an npm shim to node.exe plus the script and bypasses cmd.exe. It is a
no-op on POSIX and for any non-shim executable.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: a17f635356

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 24, 2026
Both assertions only passed because unsloth_cli/tests runs on ubuntu-latest
only. On windows-latest they fail:

  test_prefer_cmd_sibling_is_none_safe_and_posix_noop asserted no rewrite
  without pinning os.name, so on Windows the rescue fired and the assert
  checked the opposite of its intent. Pin os.name to posix.

  test_resolved_launch_command_rescues_uppercase_cmd_sibling compared path
  spelling, but a case-insensitive volume answers the earlier .cmd probe with
  the .CMD file, so the returned spelling differs while the file is the same.
  Compare with os.path.samefile.

Confirmed against a real windows-latest runner. Neither is a defect in the
shipped helper; both were tests asserting something false on Windows.
danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Aug 24, 2026
danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Aug 24, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: cea39fef1e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to my earlier review. I said then that no real Windows host had run any of this and that a confirmation from one would be worth having, so I went and got one: the branch was replicated onto a disposable staging repo and the CLI tests were run on real ubuntu-latest, macos-15 and windows-latest runners under Python 3.12.

That immediately found two tests that were wrong, one of them mine.

What the real runners found

unsloth_cli/tests only runs on ubuntu-latest in CI (studio-backend-ci.yml), so nothing here had ever executed on the platform this fix targets. On Windows:

FAILED test_prefer_cmd_sibling_is_none_safe_and_posix_noop
  assert 'C:\...\fake-agent.cmd' == 'C:\...\fake-agent'
FAILED test_resolved_launch_command_rescues_uppercase_cmd_sibling
  assert [...'.cmd', '--flag'] == [...'.CMD', '--flag']

The first asserted that a POSIX host never rewrites a resolution, but never pinned os.name, so on a Windows runner the rescue fired and the assertion checked the opposite of its intent. The second was the .CMD test I added: it compared path spelling, but a case-insensitive volume answers the earlier .cmd probe with the .CMD file, so the returned spelling differs while the file is the same. macOS failed on that one too, since APFS is case-insensitive by default, which means the bug was never Windows-specific.

Both are fixed in cea39fef1: pin os.name in the first, compare identity with os.path.samefile in the second. Neither was a defect in the shipped helper, only in tests asserting something false off Linux.

Results after the fix

runner result
ubuntu-latest 550 passed
macos-15 550 passed
windows-latest 522 passed, 9 failed, 19 skipped

Both fixed tests now pass on Windows, checked by name rather than inferred from the count. The .CMD probe is still pinned: removing that entry from the tuple fails the suite.

The 9 remaining Windows failures are pre-existing and not this branch's doing. Each was checked against the merge base and this branch touches none of them: chmod-bit assertions (33206 & 63, meaningless on Windows), WindowsPath.parents, a CODEX_HOME KeyError, and the studio server argv. They are simply invisible today because that suite is ubuntu-only. Worth a separate look, but not here.

Subagent CI

All seven connection jobs pass (claude, codex, hermes, openclaw, opencode x2, pi), which is the closest thing to end-to-end coverage of the MCP bridge change in 544143f.

The two red checks

Neither is caused by this branch, and I checked both against main rather than assuming:

  • Repo tests (CPU) is in Backend CI, which is red on main for six consecutive runs and fails on a README -H 0.0.0.0 assertion. This branch changes six unsloth_cli files and no README, so there is nothing here to fix, and re-running will not help since the failure is deterministic. It does mean this PR cannot show a fully green CI while main is in that state.
  • Chat UI Tests (banner) is in Unsloth UI CI, red on most recent main runs, failing with vite exited with code 127 while its own checks report 0 failed. That is a missing binary rather than a code defect, so I re-ran it.

Still not verified

No live agent was ever spawned through a real Windows npm shim. The Windows evidence covers the resolver logic and the test suite on a real Windows filesystem, plus documented CreateProcess behaviour; it does not cover an actual unsloth start codex launch on a machine with the pnpm layout from #9167. Anyone hitting the original bug confirming it on their own box would still be the last mile.

I had written 3.12.0 to 3.12.9 and cited gh-127001. Measured on real
windows-latest runners instead: only 3.12.0 returns the bare name, and
3.12.1, 3.12.2, 3.12.3, 3.12.7, 3.12.10, 3.11.9 and 3.13.15 all return the
.CMD sibling. That is gh-109590, fixed in 3.12.1, not the later gh-127001.
The original wording naming 3.12.0 alone was right and my edit broke it.
@danielhanchen
danielhanchen merged commit dfc4b3c into unslothai:main Aug 25, 2026
42 of 43 checks passed
lonexreb added a commit to lonexreb/unsloth that referenced this pull request Aug 28, 2026
unsloth_cli/tests runs only on ubuntu, yet the launcher's hardest paths
are Windows-shaped: npm .cmd shims, the sys.executable re-exec,
PowerShell --no-launch recipes, CREATE_NEW_PROCESS_GROUP. Reviewing
unslothai#9238 on a real windows-latest runner found 9 failures in test_start.py,
all tests asserting POSIX shapes of behavior that is deliberately
different on Windows:

- two chmod assertions: private-mode bits, which Windows does not model
- two --no-launch recipes: PowerShell has no VAR=value prefix form, so
  the self-contained-last-line contract is POSIX; assert the $env: block
- the studio server argv and process-group kwargs: Windows launches
  through sys.executable -X utf8 -c (unslothai#8490) with creationflags
- the Pi extension path: separators
- two unwritable-root fallbacks: staged via POSIX dir modes, skipped

Verified on a real windows-latest runner: test_start.py 501 passed,
0 failed (from 9). The new Backend CI job runs exactly that file; the
rest of unsloth_cli/tests still carries ~50 Windows failures whose
per-file distribution shifts with the installed dependency set, so a
broader leg would flake rather than guard.
lonexreb added a commit to lonexreb/unsloth that referenced this pull request Aug 30, 2026
unsloth_cli/tests runs only on ubuntu, yet the launcher's hardest paths
are Windows-shaped: npm .cmd shims, the sys.executable re-exec,
PowerShell --no-launch recipes, CREATE_NEW_PROCESS_GROUP. Reviewing
unslothai#9238 on a real windows-latest runner found 9 failures in test_start.py,
all tests asserting POSIX shapes of behavior that is deliberately
different on Windows:

- two chmod assertions: private-mode bits, which Windows does not model
- two --no-launch recipes: PowerShell has no VAR=value prefix form, so
  the self-contained-last-line contract is POSIX; assert the $env: block
- the studio server argv and process-group kwargs: Windows launches
  through sys.executable -X utf8 -c (unslothai#8490) with creationflags
- the Pi extension path: separators
- two unwritable-root fallbacks: staged via POSIX dir modes, skipped

Verified on a real windows-latest runner: test_start.py 501 passed,
0 failed (from 9). The new Backend CI job runs exactly that file; the
rest of unsloth_cli/tests still carries ~50 Windows failures whose
per-file distribution shifts with the installed dependency set, so a
broader leg would flake rather than guard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: unsloth start codex/pi can fail with WinError 193 when npm/pnpm extensionless shim is resolved before .cmd

3 participants