Skip to content

fix: avoid Windows npm spawn failure in Pro install - #735

Merged
rafaelscosta merged 1 commit into
mainfrom
fix/windows-pro-artifact-npm-spawn
May 14, 2026
Merged

fix: avoid Windows npm spawn failure in Pro install#735
rafaelscosta merged 1 commit into
mainfrom
fix/windows-pro-artifact-npm-spawn

Conversation

@rafaelscosta

@rafaelscosta rafaelscosta commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Summary\n- fix Pro artifact extraction/install npm invocation on Windows by preferring node + npm-cli.js\n- fall back to shell execution for npm.cmd when npm_execpath is unavailable\n- bump @aiox-squads/core/aiox-core to 5.2.4 and installer to 3.3.4\n\n## Validation\n- npm test -- tests/installer/pro-setup-auth.test.js --runInBand\n- npm run lint -- --no-cache packages/installer/src/wizard/pro-setup.js tests/installer/pro-setup-auth.test.js\n- npm test -- tests/installer/pro-setup-auth.test.js tests/unit/wizard/validation/dependency-validator.test.js --runInBand\n- npm run validate:publish

Summary by CodeRabbit

  • Chores

    • Updated package versions for core (5.2.3 → 5.2.4) and installer (3.3.3 → 3.3.4)
  • Bug Fixes

    • Improved pro setup installation reliability across different platforms
  • Tests

    • Added test coverage for npm invocation scenarios

Review Change Stack

@vercel

vercel Bot commented May 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
aiox-core Ready Ready Preview, Comment May 14, 2026 3:03pm

Request Review

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f6052d27-7f0f-49c9-a329-feac4c91d39f

📥 Commits

Reviewing files that changed from the base of the PR and between e5b7cf5 and 2b5c3b5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • compat/aiox-core/package.json
  • package.json
  • packages/installer/package.json
  • packages/installer/src/wizard/pro-setup.js
  • tests/installer/pro-setup-auth.test.js

Walkthrough

This pull request centralizes npm command invocation in the installer wizard through shared helper functions that handle platform-specific execution. The Pro artifact installation steps are refactored to use the new abstraction, test coverage validates the cross-platform invocation resolution, and package versions are incremented across the root, installer, and compatibility wrapper packages.

Changes

NPM Invocation Refactoring and Version Updates

Layer / File(s) Summary
NPM invocation helpers and export
packages/installer/src/wizard/pro-setup.js
Introduces stripWrappingQuotes, resolveNpmInvocation, and runNpm helpers that normalize npm_execpath, resolve the correct npm command and prefix arguments based on platform and environment context, and execute npm with consistent promisified execFile options. Exposes resolveNpmInvocation via _testing for testability.
Pro artifact install refactoring
packages/installer/src/wizard/pro-setup.js
Updates extractProArtifactToTemp and installProArtifactIntoTarget to replace direct npm binary selection and execFileAsync calls with runNpm(...) invocations, centralizing npm execution logic for both temporary and target artifact installations.
NPM invocation tests
tests/installer/pro-setup-auth.test.js
Adds a new test suite validating proSetup._testing.resolveNpmInvocation across three scenarios: Windows with npm_execpath (expects Node command with npm-cli.js prefix), Windows fallback (expects npm.cmd with shell: true), and POSIX (expects direct npm with default options).
Package version updates
package.json, packages/installer/package.json, compat/aiox-core/package.json
Increments root package version from 5.2.3 to 5.2.4, installer package version from 3.3.3 to 3.3.4, and updates compat wrapper version and its @aiox-squads/core dependency to 5.2.4.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

area: core, area: installer, area: pro, type: test

Suggested reviewers

  • Pedrovaleriolopez
  • oalanicolas
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: addressing Windows npm spawn failure during Pro installation, which aligns with the core changes in pro-setup.js.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-pro-artifact-npm-spawn

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added type: test Test coverage and quality area: installer Installer and setup (packages/installer/) area: docs Documentation (docs/) labels May 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📊 Coverage Report

Coverage report not available

📈 Full coverage report available in Codecov


Generated by PR Automation (Story 6.1)

@rafaelscosta
rafaelscosta merged commit b48c475 into main May 14, 2026
42 checks passed
@rafaelscosta
rafaelscosta deleted the fix/windows-pro-artifact-npm-spawn branch May 14, 2026 15:10
rafaelscosta added a commit that referenced this pull request May 17, 2026
…json (#742)

* fix(installer): isolate Pro install from ancestor workspaces/package.json

Cohort students hit "Pro activation failed: Installed Pro artifact did not
create node_modules/@aiox-squads/pro" even though npm install exits 0 and
the upstream Pro license activation completes successfully.

Root cause: installProArtifactIntoTarget runs `npm install <tgz>` in
targetDir without --prefix or --workspaces=false. npm 10+ walks the
directory tree, finds the first ancestor with a package.json (or one
declaring workspaces), and installs node_modules there instead of in the
target. The post-install integrity check then fails because the artifact
is in the wrong place, not because it never downloaded.

This was reproduced locally in 4 install topologies before patching,
then proved by running the new test suite against pre-fix code — the
two ancestor-hijack scenarios fail cleanly without the fix:

  1. workspace declared in ancestor → npm installs at workspace root (FAILS pre-fix)
  2. plain package.json in ancestor → npm installs at ancestor (FAILS pre-fix)
  3. empty targetDir, clean ancestor → works (current happy path)
  4. targetDir with own package.json → works (current happy path)

Fixes applied:

* installProArtifactIntoTarget: pass --prefix=targetDir +
  --workspaces=false + --include-workspace-root=false; create a synthetic
  anchor package.json if targetDir is empty, then clean it up after.
* extractProArtifactToTemp: mirror the same flags to harden the temp
  extraction (it never failed in practice because os.tmpdir() has no
  ancestors with package.json, but the asymmetry was fragile).
* acquireProArtifactSourceDir: when the target install fails, fall back
  to the extracted (sha256-verified) Pro source from tempRoot and emit
  a warning instead of bricking the wizard. The scaffolder copies files
  from the source dir, so the target install is a convenience, not a
  requirement. The warning is explicit that subsequent `aiox install`
  calls in the same directory will re-download Pro until the user runs
  from a fresh empty directory.
* New diagnostic helper findAncestorNodeModulesPro walks up to 8 levels
  looking for a stray install, included in the user-facing error so
  students can see where npm actually put the package.

Tests added: tests/installer/pro-setup-target-install.test.js — 8
regression tests covering all four install topologies, the synthetic
anchor cleanup, the diagnostic helper (positive + negative cases), and
the graceful fallback contract in acquireProArtifactSourceDir.
Integration-style: builds a minimal fixture tarball at runtime via
`npm pack`, no external dependencies, no Supabase credentials needed.

CI added: .github/workflows/installer-smoke-matrix.yml — runs the
regression suite + three end-to-end smoke installs (empty target,
nested in workspace, nested under plain package.json) on Ubuntu/macOS/
Windows with Node 18/20/22 and npm 8/10/11. Triggers on
packages/installer/** and tests/installer/** changes, breaking the
"11 fixes to pro-setup.js in 30 days, each catching a new edge case"
pattern by validating the install surface itself before publish.

Cleared the dead fallback path in acquireProArtifactSourceDir that was
already wired (`installedProSourceDir || extractedProSourceDir`) but
unreachable because the throw in installProArtifactIntoTarget short-
circuited it.

Affected story: PRO-13.6 (signed artifact pipeline)
Builds on: #735 (Windows npm spawn), PRO-13.5 (private distribution)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(installer-smoke): address CodeRabbit feedback on PR #742

* Use platform-aware npm binary (npm.cmd on Windows) in the test fixture
  tarball builder and the 3 inline smoke install scripts in
  installer-smoke-matrix.yml. Mirrors the pattern in pro-setup.js'
  resolveNpmInvocation. Without this, the Windows job fixed below would
  fail at the `execFileSync('npm', ...)` call.
* Replace the cross-product matrix with an explicit `include:` list and
  drop combos that are structurally invalid (and were failing CI on the
  first run): Node 18 + npm 11 (npm 11 requires Node >= 20.17), Node 20
  + npm 8 (npm 8 too old to honor --workspaces=false reliably), and the
  redundant npm 11 re-pin on Node 22 (already ships with npm 11; the
  re-pin via `npm install --global` conflicts with the bundled install
  on GitHub-hosted runners). Added a new `bundled` mode that skips the
  pin step entirely.
* Coverage retained: Ubuntu (Node 18/20/22 × npm 10/11/bundled),
  macOS (Node 20/22), Windows (Node 20/22). 8 combos total, all valid.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tuanmedeiros pushed a commit to tuanmedeiros/aios-core-synkraay that referenced this pull request Jun 2, 2026
tuanmedeiros pushed a commit to tuanmedeiros/aios-core-synkraay that referenced this pull request Jun 2, 2026
…json (SynkraAI#742)

* fix(installer): isolate Pro install from ancestor workspaces/package.json

Cohort students hit "Pro activation failed: Installed Pro artifact did not
create node_modules/@aiox-squads/pro" even though npm install exits 0 and
the upstream Pro license activation completes successfully.

Root cause: installProArtifactIntoTarget runs `npm install <tgz>` in
targetDir without --prefix or --workspaces=false. npm 10+ walks the
directory tree, finds the first ancestor with a package.json (or one
declaring workspaces), and installs node_modules there instead of in the
target. The post-install integrity check then fails because the artifact
is in the wrong place, not because it never downloaded.

This was reproduced locally in 4 install topologies before patching,
then proved by running the new test suite against pre-fix code — the
two ancestor-hijack scenarios fail cleanly without the fix:

  1. workspace declared in ancestor → npm installs at workspace root (FAILS pre-fix)
  2. plain package.json in ancestor → npm installs at ancestor (FAILS pre-fix)
  3. empty targetDir, clean ancestor → works (current happy path)
  4. targetDir with own package.json → works (current happy path)

Fixes applied:

* installProArtifactIntoTarget: pass --prefix=targetDir +
  --workspaces=false + --include-workspace-root=false; create a synthetic
  anchor package.json if targetDir is empty, then clean it up after.
* extractProArtifactToTemp: mirror the same flags to harden the temp
  extraction (it never failed in practice because os.tmpdir() has no
  ancestors with package.json, but the asymmetry was fragile).
* acquireProArtifactSourceDir: when the target install fails, fall back
  to the extracted (sha256-verified) Pro source from tempRoot and emit
  a warning instead of bricking the wizard. The scaffolder copies files
  from the source dir, so the target install is a convenience, not a
  requirement. The warning is explicit that subsequent `aiox install`
  calls in the same directory will re-download Pro until the user runs
  from a fresh empty directory.
* New diagnostic helper findAncestorNodeModulesPro walks up to 8 levels
  looking for a stray install, included in the user-facing error so
  students can see where npm actually put the package.

Tests added: tests/installer/pro-setup-target-install.test.js — 8
regression tests covering all four install topologies, the synthetic
anchor cleanup, the diagnostic helper (positive + negative cases), and
the graceful fallback contract in acquireProArtifactSourceDir.
Integration-style: builds a minimal fixture tarball at runtime via
`npm pack`, no external dependencies, no Supabase credentials needed.

CI added: .github/workflows/installer-smoke-matrix.yml — runs the
regression suite + three end-to-end smoke installs (empty target,
nested in workspace, nested under plain package.json) on Ubuntu/macOS/
Windows with Node 18/20/22 and npm 8/10/11. Triggers on
packages/installer/** and tests/installer/** changes, breaking the
"11 fixes to pro-setup.js in 30 days, each catching a new edge case"
pattern by validating the install surface itself before publish.

Cleared the dead fallback path in acquireProArtifactSourceDir that was
already wired (`installedProSourceDir || extractedProSourceDir`) but
unreachable because the throw in installProArtifactIntoTarget short-
circuited it.

Affected story: PRO-13.6 (signed artifact pipeline)
Builds on: SynkraAI#735 (Windows npm spawn), PRO-13.5 (private distribution)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(installer-smoke): address CodeRabbit feedback on PR SynkraAI#742

* Use platform-aware npm binary (npm.cmd on Windows) in the test fixture
  tarball builder and the 3 inline smoke install scripts in
  installer-smoke-matrix.yml. Mirrors the pattern in pro-setup.js'
  resolveNpmInvocation. Without this, the Windows job fixed below would
  fail at the `execFileSync('npm', ...)` call.
* Replace the cross-product matrix with an explicit `include:` list and
  drop combos that are structurally invalid (and were failing CI on the
  first run): Node 18 + npm 11 (npm 11 requires Node >= 20.17), Node 20
  + npm 8 (npm 8 too old to honor --workspaces=false reliably), and the
  redundant npm 11 re-pin on Node 22 (already ships with npm 11; the
  re-pin via `npm install --global` conflicts with the bundled install
  on GitHub-hosted runners). Added a new `bundled` mode that skips the
  pin step entirely.
* Coverage retained: Ubuntu (Node 18/20/22 × npm 10/11/bundled),
  macOS (Node 20/22), Windows (Node 20/22). 8 combos total, all valid.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Documentation (docs/) area: installer Installer and setup (packages/installer/) type: test Test coverage and quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant