Skip to content

fix(cli): configure Windows PATH and bin shims on global npm install - #430

Open
m-golovchin wants to merge 11 commits into
codemie-ai:mainfrom
m-golovchin:fix/npm-windows-path-shims
Open

fix(cli): configure Windows PATH and bin shims on global npm install#430
m-golovchin wants to merge 11 commits into
codemie-ai:mainfrom
m-golovchin:fix/npm-windows-path-shims

Conversation

@m-golovchin

Copy link
Copy Markdown
Collaborator

Summary

Fixes npm install -g @codemieai/code on Windows not adding PATH entries or creating bin shims.

Adds a postinstall.mjs script that runs after installation and:

  • Detects the npm prefix directory on Windows (no /bin suffix unlike Unix)
  • Writes the prefix directory to the Windows user PATH via the registry (addToUserPath from dist/utils/windows-path.js)
  • Warns if expected bin shims (.cmd files) are missing
  • Falls back gracefully if dist/utils/windows-path.js is not built yet
  • On Unix, appends the npm bin directory to ~/.zshrc, ~/.bash_profile, or ~/.bashrc

Also includes supporting tooling fixes discovered during test development:

  • Removes #!/usr/bin/env node hashbang from postinstall.mjs — Vite SSR transform prepends generated code before the file, pushing the hashbang past position 0 and causing SyntaxError in all unit tests
  • Migrates vitest.config.ts from deprecated poolOptions.threads.{maxThreads,minThreads} to top-level maxWorkers/minWorkers (Vitest 4.x)
  • Double-quotes ESLint glob patterns in package.json; single-quoted brace expansion fails on Windows cmd.exe, and unquoted ** only expands one level deep on Unix sh

Changes

  • scripts/postinstall.mjs — Windows PATH + shim diagnostic implementation (27 unit tests in scripts/__tests__/postinstall.test.ts)
  • scripts/postinstall.mjs — remove hashbang; fix isMain guard
  • vitest.config.ts — Vitest 4 poolOptions migration
  • package.json — cross-platform ESLint glob fix

Testing

  • 27 unit tests added covering all exported functions and Windows/Unix branches
  • npm run check:pre-commit passes (typecheck + lint clean)
  • Manual install verified on Windows 11: codemie --version resolves after fresh npm install -g, PATH set in registry, all .cmd shims present

Checklist

  • Code follows project standards
  • No merge conflicts with main

Closes EPMCDME-13191

MaksymHolovchyn added 11 commits July 21, 2026 13:47
…binary

engineBin is already a fully-resolved absolute path from where/which, so
shell:true is unnecessary and re-splits paths containing spaces (e.g.
"C:\Program Files\Docker\...") into invalid commands on Windows.
…ilable

CR-001: runWindows()'s dynamic import and its calls were unguarded, so a
missing dist/ (e.g. Windows CI's npm ci step running before dist/ is
downloaded, or a fresh clone before npm run build) crashed postinstall
with an uncaught rejection instead of degrading like every other
non-actionable failure mode.
Technical analysis, complexity assessments (initial + actual), spec,
plan, code review verdicts, and QA report for the npm Windows PATH fix.
…tern

- Remove #!/usr/bin/env node from postinstall.mjs; Vite SSR transform
  prepends generated code pushing the hashbang past position 0, causing
  SyntaxError in all 27 postinstall tests
- Migrate vitest.config.ts from deprecated poolOptions.threads to top-level
  maxWorkers/minWorkers (Vitest 4.x breaking change)
- Double-quote ESLint glob patterns; single-quoted brace expansion fails on
  Windows cmd.exe, unquoted ** only expands one level deep on Unix sh

EPMCDME-13191
@m-golovchin
m-golovchin force-pushed the fix/npm-windows-path-shims branch from 8d22d0c to 4033405 Compare July 21, 2026 10:49
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