Skip to content

test(cli): run the Core rebuild through cmd.exe on Windows - #11051

Merged
cixzhang merged 3 commits into
meta:mainfrom
prath47:windows-pnpm-spawn
Nov 11, 2026
Merged

cixzhang merged 3 commits into
meta:mainfrom
prath47:windows-pnpm-spawn

Conversation

@prath47

@prath47 prath47 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

On Windows, the CLI test suite can't start once Core's sources are newer than its build. That happens after any pull, branch switch or edit under packages/core. Since #8567 the node global setup rebuilds a stale Core with execFileSync('pnpm', …), and that call fails before a single test runs:

Error: spawnSync pnpm ENOENT
 ❯ buildCore packages/cli/clients/cli/commands/ensure-core-built.mjs:234:3
 ❯ ensureBuiltOnce packages/cli/clients/cli/commands/ensure-core-built.mjs:314:11
 ❯ ensureCoreBuiltAt packages/cli/clients/cli/commands/ensure-core-built.mjs:345:3
 ❯ ensureCoreBuiltForRunAt packages/cli/clients/cli/commands/ensure-core-built.mjs:451:3
 ❯ Object.setup vitest.global-setup.node.mjs:60:5

The usual ways of getting pnpm on Windows (corepack, npm i -g pnpm, the standalone installer's shims) put a pnpm.cmd batch file on PATH. execFileSync can't start a batch file without a shell. A bare pnpm isn't resolved through PATHEXT, so you get ENOENT, and pnpm.cmd gives EINVAL (Node refuses batch files without a shell since the CVE-2024-27980 fix).

The only workaround today is building Core by hand before every test run, which isn't obvious from the error.

Intended invariant

The node global setup rebuilds a Core build older than its sources before the workers start (#8567). That should hold on every platform contributors use, not only where pnpm is a real executable.

Change

In buildCore(), on win32 only, run cmd.exe /d /s /c pnpm -F @astryxdesign/core build instead of pnpm directly. This is the same pattern internal/vibe-tests already uses (#5841, #5843). The arguments are literals, so we avoid shell: true and its DEP0190 warning. Options (cwd, stdio: 'pipe', timeout) are unchanged, and macOS/Linux take exactly the old path.

The two other bare execFileSync('pnpm', …) calls are in .github/scripts/ (visual-gate/lib/sources.mjs, cli-api-types-verify.mjs), which only run on Linux runners. I left them alone to keep this to the one call that blocks local test runs.

Evidence

  • Failure before the change: Windows 10, Node 24.22.1, pnpm 11.10.0 available only as pnpm.cmd on PATH. Touched packages/core/src/index.ts (mtime only) so the setup sees a stale build, then:

    pnpm exec vitest run --project node theme-checks.test -t "check 9"
    

    → Error: spawnSync pnpm ENOENT from buildCore (trace above), no tests run.

  • Success after the change: same PATH, touched the same file again, same command. The setup rebuilt Core (the dist/astryx.css marker went from older than the touched source to newer) and the run finished:

    Test Files  1 passed (1)
         Tests  4 passed | 46 skipped (50)
    
  • A failing build still fails: execFileSync('cmd.exe', ['/d', '/s', '/c', 'pnpm', '-F', '@astryxdesign/core', 'run', 'no-such-script']) throws with status 1, so a broken Core build still stops the setup instead of being swallowed by cmd.exe.

  • Product/runtime behavior verified unchanged: the file is a test helper (called by the node global setup and the build-theme suites), but it ships in the @astryxdesign/cli tarball because files includes clients. So it has a [chore] CLI patch changeset (.changeset/windows-core-rebuild.md), as test(cli): the node suites rebuild a Core build older than its sources #8567 did for this helper. changeset-coverage.mjs pr --base origin/main now reports it ships to @astryxdesign/cli and is named. No CLI command changes behavior.

  • CI impact: no workflow or job changes. On Linux CI the rebuild runs the same pnpm command as before. The changeset is what the required lint job checks for.

Scope

Components: CLI test setup (packages/cli/clients/cli/commands/ensure-core-built.mjs)

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • Before/after runs above, on Windows with only pnpm.cmd on PATH.
  • pnpm exec prettier --check and pnpm exec eslint on the changed file: clean.
  • pnpm -F @astryxdesign/cli typecheck:strict: no errors in this file. The only errors are two existing assets/templates imports of @astryxdesign/theme-neutral/built, which need that package built locally.
  • Pre-commit hook passed.
  • pnpm check:changesets and changeset-coverage.mjs pr --base origin/main pass on the head.
  • I couldn't run it on macOS/Linux here, but the non-Windows branch is the same execFileSync('pnpm', args, options) call as before.

The node global setup rebuilds a stale Core with execFileSync('pnpm').
On Windows pnpm is a pnpm.cmd batch file, which execFileSync can't start
without a shell, so the setup dies with "spawnSync pnpm ENOENT" and no CLI
test runs whenever Core's sources are newer than its build.

Route the call through cmd.exe /d /s /c on win32, the same way the
vibe-tests helpers do since meta#5841 and meta#5843. Every argument is a literal,
so this avoids shell: true and its DEP0190 warning. Other platforms are
unchanged.
@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 11, 2026 3:27pm UTC

Request Review

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 10, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 10, 2026
@astracat-bot

astracat-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 11, 2026, 3:26 PM UTC

@astracat-bot astracat-bot Bot 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.

Thanks for tracking this down. Routing the rebuild through cmd.exe /d /s /c on Windows matches what internal/vibe-tests already does, and the macOS/Linux path is unchanged. One existing test needs an update before this can merge.

Blocking

  • packages/cli/foundation/doc-compiler/doc-loads.test.mjs ("lists each one with exactly the sites it has") now fails: buildCore() has two execFileSync calls, and the file's entry lists one (ensure-core-built.mjs runs [child_process.execFileSync ×2], listed [child_process.execFileSync]).

Next step: pick the executable and its arguments by platform and keep a single execFileSync(file, fileArgs, options) call, which passes the test as it is, or change the entry to child_process.execFileSync ×2.

[Automated review]

doc-loads.test.mjs lists each file's child_process sites, and the
platform branch had made two. Pick the executable and its arguments by
platform and keep the single call.

@astracat-bot astracat-bot Bot 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.

Approved pending CI: CI has not run on this head yet; a maintainer adds the ci:run label so CI runs.

Routing the Core rebuild through cmd.exe /d /s /c pnpm on Windows fixes the setup failure while macOS and Linux keep the same pnpm call, and the single execFileSync call keeps doc-loads.test.mjs green. Nothing else needs to change here. As an optional follow-up, authoring-migration.tsc.test.mjs still calls pnpm directly and hits the same Windows error.

[Automated review]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · ddf4d84

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 3.57 MB packed (+200 B); no new dependencies.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@cixzhang
cixzhang marked this pull request as draft November 10, 2026 22:23
@cixzhang
cixzhang marked this pull request as ready for review November 10, 2026 22:23

@astracat-bot astracat-bot Bot 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.

Changes requested: one fix before this can merge.

  • Found by CI: the required lint check fails at "Check Changeset coverage" because packages/cli/clients/cli/commands/ensure-core-built.mjs ships in the @astryxdesign/cli tarball (its files include clients), so please add a Changeset naming '@astryxdesign/cli': patch with a [chore] summary, as #8567's .changeset/core-build-freshness.md did for this helper.

Routing the rebuild through cmd.exe /d /s /c pnpm on Windows looks right, and macOS and Linux keep the same call. Please also correct the description's "nothing here ships to consumers" and "CI impact: none" lines, which this CI run contradicts.

[Automated review]

ensure-core-built.mjs ships in the @astryxdesign/cli tarball, so the
change needs a CLI patch changeset, as meta#8567's did for this helper.

@astracat-bot astracat-bot Bot 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.

Approved pending CI: CI is still running on this head.

The new @astryxdesign/cli Changeset covers ensure-core-built.mjs, so the Changeset coverage check now passes, and routing the Core rebuild through cmd.exe /d /s /c pnpm on Windows keeps macOS and Linux on the same call as before.

  • Optional: the description still says the coverage check "reports nothing here ships to consumers, so no changeset" and "CI impact: none"; updating those two lines would match the Changeset this head adds.

Automated review (maintainer link)

@prath47

prath47 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Added the changeset in ddf4d84 (.changeset/windows-core-rebuild.md, '@astryxdesign/cli': patch, [chore]), worded like #8567's. changeset-coverage.mjs pr --base origin/main now reports ships @astryxdesign/cli ... ensure-core-built.mjs and passes, and pnpm check:changesets passes.

You're right about the description. My earlier coverage run was against an uncommitted tree, so it compared nothing. I've corrected the "nothing here ships" and "CI impact" lines.

I'll leave authoring-migration.tsc.test.mjs for a separate PR so this one stays one change.

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 11, 2026
@cixzhang
cixzhang merged commit 56c05cc into meta:main Nov 11, 2026
71 checks passed

This branch was successfully deployed

1 active deployment
Preview — ddf4d842 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants