Skip to content

vp staged: Windows CreateProcess fails with command line too long when many files are staged for vp fmt #3576

Backlog

Description

@CaiPeng1989

Describe the bug

What I am doing

In a monorepo on Windows, I stage a large number of files (100+) under a long path prefix (e.g. apps/site/vp-content/**/*.md) and run git commit --trailer "Co-authored-by: Cursor <cursoragent@cursor.com>". The pre-commit hook runs vp staged, which executes the configured task:

staged: {
  '*': 'vp fmt --no-error-on-unmatched-pattern',
},

What I expect

vp staged / bundled lint-staged should split the file list into chunks (Windows maxArgLength ≈ 8191) so vp fmt can run successfully across all staged files.

What actually happens

The pre-commit hook fails with a localized Windows error equivalent to "The command line is too long" (文件名太长). The commit is aborted / reverted by lint-staged.

vp staged --debug shows we are on lint-staged@17.6.2 with maxArgLength: 8191, so chunking appears configured — but a single invocation still seems to hit the Windows CreateProcess limit when many absolute paths are passed to vp fmt.

Notes

  • Manual vp fmt <directory> works fine (not an oxfmt throughput issue).
  • Staging ~25 files at a time succeeds; staging ~100+ fails.
  • Related upstream: lint-staged#147 (Windows ARG_MAX / chunking).
  • Vite+ docs / vp staged --help do not expose --max-arg-length.

Possible directions

  1. Expose --max-arg-length (or a safer default for absolute paths) on vp staged.
  2. Prefer --relative paths when invoking vp fmt from staged tasks.
  3. Document a recommended staged pattern for large monorepos / generated trees on Windows.

Reproduction

N/A — private monorepo; see Steps (Windows CreateProcess ARG_MAX with vp staged + 100+ absolute paths). Related: lint-staged/lint-staged#147

Steps to reproduce

  1. On Windows, clone/open a monorepo with Vite+ (vp staged in pre-commit).
  2. Configure staged: { '*': 'vp fmt --no-error-on-unmatched-pattern' }.
  3. Modify and git add 100+ files with long paths (e.g. apps/site/vp-content/**/*.md).
  4. Run git commit --trailer "Co-authored-by: Cursor <cursoragent@cursor.com>" -m "test".
  5. Observe pre-commit fail with Windows command-line-too-long (文件名太长).
  6. Compare: git add only ~25 of those files → commit succeeds.
  7. Compare: vp fmt apps/site/vp-content (directory arg) succeeds.

System Info

OS: Windows (win32) 10.0.26300
Node: v24.21.0
Git: 2.38.1.windows.1
Shell: PowerShell

vp --version:
vp v1.8.0

Local vite-plus:
  vite-plus  v1.8.0

Tools:
  vite      v8.3.8
  rolldown  v1.2.19
  vitest    v5.1.1
  oxfmt     v0.79.0
  oxlint    v1.94.0
  tsrs      v7.1.0-beta.tsrs4
  tsdown    v0.23.4

vp env current: unavailable via local `pnpm exec vp` (requires global vp CLI).

Additional:
lint-staged (via `vp staged --debug`): 17.6.2, maxArgLength: 8191

Used Package Manager

pnpm

Logs

Validations

Activity

  1. added theissue type on Nov 25, 2026
  2. voidzero-bot commented on Nov 25, 2026

    @voidzero-bot
    Contributor
    • Reproduced: Skipped — the failure is triggered by the Windows CreateProcess command-line limit (8191 chars) and cannot be exercised on the Linux triage runner. Control runs on Linux confirm the chunking pipeline itself works on the current checkout.
    • Exploration: Partial
    • Unit Test: No — the failure requires a Windows host; the Linux control cases (151 and 851 staged files) both succeeded with exit 0, so there is no failing test to add on this platform.
    • Priority: Priority P3: minor bug. This is an edge case affecting a specific setup — Windows users with 100+ staged files under long path prefixes — and a straightforward workaround already exists today: running vp staged --relative (exposed as -r) shortens the file list passed to vp fmt, and committing in smaller batches also works. It does not affect core workflows for most users.

    The reported failure is specific to Windows: lint-staged (17.6.2, bundled by vp staged) picks a per-platform chunk budget (win32 → 8191, Linux → 131072) and on Windows that budget equals the OS command-line limit exactly, leaving no headroom for quoting/escaping or any wrapper overhead in the actual spawned command line. On Linux, control runs showed lint-staged correctly splitting an 851-file staged set (346 KB of absolute paths) into chunks and running four concurrent vp fmt invocations successfully — the chunking mechanism itself works end-to-end on the current checkout.

    I wasn't able to find a fix, but I identified some areas that may be relevant. packages/cli/src/staged/bin.ts passes through a fixed allow-list of lint-staged flags but omits maxArgLength, and vp staged --help does not expose --max-arg-length, even though upstream lint-staged supports it — so users on Windows cannot lower the 8191 budget to leave headroom for quoting overhead. As a stopgap, the already-available -r/--relative flag (or --concurrent false) reduces command-line pressure and is documented in vp staged --help. Diagnosis of the exact Windows spawn path would need a Windows host.

    Full Triage Report

    Triage Report — Issue #3576

    Title: vp staged: Windows CreateProcess fails with command line too long when many files are staged for vp fmt
    Step: reproduce
    Result: Skipped — host-specific (Windows-only trigger; not reproducible on the Linux runner). Control runs on Linux confirm the chunking pipeline itself works on the current checkout.

    Issue summary

    • Expected: vp staged (bundled lint-staged) splits the staged file list so each spawned vp fmt invocation stays within the OS command-line limit (Windows ≈ 8191 chars).
    • Actual (reported): On Windows with 100+ staged files under a long path prefix, the pre-commit hook fails with the localized CreateProcess error "The command line is too long" (文件名太长); the commit is aborted. ~25 files at a time works; vp fmt <dir> works.
    • Reporter is on vp/vite-plus v1.8.0, lint-staged 17.6.2, maxArgLength: 8191, Node v24.21.0, Windows 10.0.26300.

    Environment used for triage

    Component Version
    OS Linux x86_64 (Ubuntu runner)
    vp --version v1.8.0 (built from current checkout, on PATH)
    Local vite-plus v1.8.0 (checkout, linked into repro)
    Node.js v24.22.3
    pnpm v12.11.2
    Bundled oxfmt v0.80.0
    Bundled lint-staged 17.6.2 (via vp staged --debug)
    Linux ARG_MAX 4,194,304

    Why reproduction is skipped (host-specific)

    The reported failure is the Windows CreateProcess/cmd.exe command-line-length limit (8191 chars). lint-staged picks the chunk budget per platform (node_modules/.pnpm/lint-staged@17.6.2/.../lib/getMaxArgLength.js):

    • win32 → 8191
    • darwin → 262144
    • default (Linux) → 131072

    On Linux the chunk budget (131072) is far below the actual execve limit (~4 MB, getconf ARG_MAX = 4194304), so the OS-level failure the reporter hit cannot be triggered on this runner. The relevant interplay (shim/wrapper command line, quoting overhead on Windows vs. the exact-8191 chunk budget) only exists on Windows.

    Commands attempted (control evidence on Linux)

    Repro: /tmp/vite-plus-triage/gh-3576/repro/monorepo — git repo with vite.config.ts:

    export default { staged: { '*': 'vp fmt --no-error-on-unmatched-pattern' } }

    node_modules/vite-plus linked to the checkout via pnpm link <repo>/packages/cli.

    1. 151 staged files (absolute paths, ~29 KB of argv text):
      vp staged → ✔ vp fmt --no-error-on-unmatched-pattern, exit 0.
      vp staged --debug → maxArgLength: 131072, no Splitting needed, "Tasks were executed successfully!".

    2. 851 staged files (absolute paths, 346,258 argv chars — well over the Linux chunk budget):
      vp staged --debug → exit 0. Debug log shows chunking engaged:

      • lint-staged:getSpawnedTasks: Splitting 851 files for maxArgLength of 131072
      • Splitting 426 files…, Splitting 425 files… → 4 chunk invocations of vp fmt run concurrently (concurrency: Infinity)
      • "Tasks were executed successfully!"

    So the chunking mechanism (split by command.length + 1 + files.join(' ').length <= maxArgLength) functions correctly end-to-end with the current checkout on Linux, including multiple concurrent vp fmt invocations on chunked subsets.

    Additional observations (confirming reporter's notes)

    • vp staged --help does not expose --max-arg-length; upstream lint-staged's own CLI does (lib/cli.js: maxArgLength: parseBoolOrNumber(values['max-arg-length'])).
    • packages/cli/src/staged/bin.ts passes through a fixed flag list (allowEmpty, debug, relative, …) but not maxArgLength, so vite-plus users cannot override the platform default of 8191 on Windows.
    • -r, --relative (pass relative filepaths to tasks) is exposed and passed through — a partial mitigation already available on the current checkout.
    • lint-staged 17 spawns tasks via tinyexec exec(cmd, [...args, ...files]) with no shell; the chunk length it measures is the unquoted command + ' ' + files.join(' '), while the real Windows command line also carries quoting/escaping and wrapper overhead — relevant headroom to examine during diagnosis on Windows, where the budget equals the OS limit exactly.
    • Note: no Windows host is available in this environment, so the exact CreateProcess failure (and any shim/cmd.exe wrapper interplay) could not be observed directly.

    Result

    • Reproduced: No — cannot be triggered on Linux; the failure is specific to the Windows command-line-length limit (issue classified as a Bug).
    • Skipped reason: host-specific (requires Windows).
    • Control: On Linux, vp staged chunked and ran vp fmt successfully for both 151-file and 851-file staged sets with long absolute paths (exit 0).

    This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Target date

    None yet

    Start date

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions