Skip to content

Windows contributors cannot run pnpm lint, the builder's typecheck and build, two test suites, or the git hooks: four independent causes #1397

Closed

Description

@rawdaymx

Summary

On Windows, a contributor who follows CONTRIBUTING.md cannot run pnpm lint, cannot run the builder's check-types or build, sees 6 test cases fail in two suites for reasons unrelated to what they assert, and cannot commit or change branches because both git hooks abort. These are four independent causes, each with its own mechanism and its own fix.

What isolates them. None of these is "Windows is unsupported" or "the machine is slow". In each case the repository already does the portable thing somewhere else, and one spot does not:

Cause Effect The portable thing already in the tree
1 spawnSync("drizzle-kit", ...) with no shell (packages/database/scripts/check-schema-drift.mjs:72) pnpm lint fails with 0 of 2 tasks successful Other scripts in the same folder run through node
2 VAR=value command prefix in two apps/builder scripts (package.json:7,8) check-types and build die before doing any work The other 7 scripts in the same file carry no env prefix; these two are the only ones in the monorepo that do
3 Path expectations built with join/relative compared against /-separated values (3 test files) 6 cases fail deterministically —
4 Multiline lefthook job bodies containing double quotes (lefthook.yml) post-checkout and commit-msg always abort, even on a valid branch name and a valid commit message The two single-line jobs in the same file work, because they contain no double quotes

Causes 1, 2 and 4 are environment-shaped and invisible on Linux CI. Cause 3 is visible as plain test failures.

Environment

Measured against upstream/main = e4913ef2a
OS / shell Windows 11, Git Bash (sh.exe from Git for Windows)
node / pnpm / turbo / lefthook v24.14.1 / 10.34.5 / 2.10.4 / 2.1.9
How Ran the repository on that machine. Exit codes read directly, never through a pipe

Cause 1 - pnpm lint cannot run at all

packages/database/scripts/check-schema-drift.mjs:72 calls spawnSync("drizzle-kit", ["generate", ...]). On Windows pnpm installs drizzle-kit as a .CMD shim, and spawnSync cannot execute a .CMD without a shell, so result.error is set and the script exits 2. That script is wired into packages/database's lint, which is wired into the root pnpm lint.

Before, root pnpm lint - exit 2:

@chatbotx.io/database:lint: [ERROR] Could not run drizzle-kit: spawnSync drizzle-kit ENOENT
 Tasks:    0 successful, 2 total
Failed:    @chatbotx.io/database#lint

After - exit 0, Tasks: 2 successful, 2 total, Cached: 0 cached. The check still does its job rather than being skipped: Schema is in sync with the migration snapshot chain.

Cause 2 - the builder's check-types and build die before starting

apps/builder/package.json:7-8 are the only two scripts in the monorepo that prefix a command with VAR=value. pnpm runs package scripts through cmd.exe on Windows, which does not understand that POSIX form.

Before - exit 1:

> NODE_OPTIONS=--max-old-space-size=8192 tsc --noEmit
'NODE_OPTIONS' is not recognized as an internal or external command,
operable program or batch file.

After - exit 0, the full typecheck completes. Both measurements were taken with no script-shell override in place, so the green is the fix and not a local workaround.

This one interacts with #1169: that issue asks for NODE_OPTIONS=--max-old-space-size=8192 to be added to six more check-types scripts. If it is added in the current form, the problem above is multiplied by six. Launching tsc through node puts the heap flag where it has to be anyway and is portable.

Cause 3 - 6 test cases compare two different path separators

Three suites build an expectation with node's join/relative, which uses a backslash on Windows, and compare it against a value that is always /-separated: the shell script's own stdout in docker-entrypoint, and a hand-written allowlist in the other two.

Baseline on e4913ef2a, full suites:

Workspace Result
worker 2 files / 5 cases failed, 263 files passed (docker-entrypoint x3, message-failed-error-stack x2)
builder 1 file / 1 case failed, 743 files passed (rpc-router-auth-surface)

With the patch, same machine, --force so nothing is cached:

Workspace Result
worker 265 files / 3198 cases passed
builder 744 files / 5884 cases passed, 2 skipped
chatbotx-mcp 12 files / 178 passed, 1 todo
@chatbotx.io/database 82 files / 1108 passed, 9 + 52 skipped

check-types across the workspace: 59 of 59 successful.

Cause 4 - both git hooks abort, whatever you type

On Windows lefthook runs a job body as sh.exe -c "<body>". The post-checkout and commit-msg bodies contain double quotes of their own - grep -qE "$PATTERN" - which close that argument early. sh then receives an if with no fi.

Verbose output, with a valid commit message (fix(env): a perfectly valid message) - exit 1:

[lefthook] run:  "C:\Program Files\Git\bin\sh.exe" -c "MSG=$(cat C:/.../msg.txt)
...
Invalid: -c: line 4: syntax error: unexpected end of file

The failure is the wrapper, not the pattern: the message satisfies the regex. The two single-line jobs in the same file (pnpm ultracite fix, pnpm turbo check-types) survive because they contain no double quotes.

With the bodies moved into scripts/git-hooks/ and invoked through sh, on the same machine:

Case Exit Behaviour
Valid commit message 0 accepted
Invalid commit message 1 rejected, with the original help text and Got: <message> intact
Branch name that does not match the pattern 1 rejected, original help text intact
Branch feat/something 0 accepted
Branch main (exempt) 0 accepted

The last three were run in a throwaway repository so the gate's rejection path could be exercised without renaming branches here. Invoking through sh rather than relying on the executable bit is deliberate: Windows checkouts do not carry it.

Where it comes from

  • packages/database/scripts/check-schema-drift.mjs:72 - spawnSync("drizzle-kit", ...)
  • apps/builder/package.json:7 and :8 - the two VAR=value prefixes
  • apps/worker/__tests__/docker-entrypoint.test.ts, apps/worker/__tests__/message-failed-error-stack.test.ts, apps/builder/__tests__/rpc-router-auth-surface.test.ts
  • lefthook.yml:4-21 (post-checkout) and :34-48 (commit-msg)

Why we think these are defects rather than the intended design

CONTRIBUTING.md and AGENTS.md describe a single setup path and never limit it to Linux or macOS, and AGENTS.md:146 makes pnpm lint the gate for considering work done - a gate a Windows contributor cannot pass for a reason that has nothing to do with their change.

Cause 4 is a lefthook limitation rather than something this repository did wrong, and we are reporting it to lefthook separately. We still think it belongs here: the hooks are this repository's, and they are unusable on Windows today. If you would rather wait for a fix upstream of lefthook, that commit is easy to drop on its own.

Suggested fix

One commit per cause, so any of them can be taken or dropped independently:

Commit Cause Shape
fix(scripts) 1 Resolve drizzle-kit's declared bin entry and launch it with process.execPath; fall back to the bare command if the entry cannot be found
build(builder) 2 node --max-old-space-size=8192 node_modules/typescript/bin/tsc --noEmit, and dotenv -v SKIP_ENV_CHECK=true (already supported by the dotenv-cli version this package depends on). No new dependency
test 3 Normalise both sides to / before comparing. Assertions, allowlists and patterns unchanged
chore(hooks) 4 Move the two bodies verbatim into scripts/git-hooks/ and invoke them through sh

Workaround for anyone hitting this

Until this lands, on Windows: put script-shell=C:/Program Files/Git/bin/bash.exe in a local .npmrc (fixes causes 1 and 2 by giving pnpm a POSIX shell), and disable the two hooks in lefthook-local.yml with skip: true (cause 4). Cause 3 has no workaround short of editing the tests. All four were verified on the machine above.

What we did not verify

  • Only one Windows machine, one node version and one pnpm version. We did not try PowerShell instead of Git Bash, nor a WSL checkout, where causes 1, 2 and 4 should not appear at all.
  • We did not run the suites for workspaces we did not touch, so this says nothing about whether other suites are green on Windows.
  • apps/mcp-server/__tests__/create-mcp-server.test.ts and apps/builder/__tests__/client-imports-no-backend-packages.test.ts have gone over their 5s and 30s budgets in loaded full-suite runs on this machine, but they passed on the baseline today (178 and 744 files green), so we have no reproducible failure to show and are deliberately not proposing a change there.
  • One extra set of failures we saw at first was our own measuring error, not this repository's: running vitest from a path whose casing differs from the filesystem's (.../documents/... instead of .../Documents/...) makes module resolution drop a path segment, and a different handful of suites fails on each run. Re-run from the correctly-cased path they all pass. Worth knowing if you ever receive a confusing Windows report, but it is not a defect here.
  • We did not measure whether apps/realtime, apps/cli or apps/javascript-executor have the same classes of problem.

Related issues - none of these describes it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions