Skip to content

fix(lefthook): Windows/Git Bash pre-commit hooks fail with node syntax error #948

Closed

Description

@goumies-creative

Description

lefthook pre-commit hooks fail on Windows/Git Bash with "node: -c: line 3: syntax error: unexpected end of file" for every hook that uses the {files} placeholder. This is a known Windows incompatibility with lefthook's file-passing mechanism.

Expected behaviour

Pre-commit hooks should run successfully on Windows/Git Bash, validating staged files (JSON, YAML, markdown links, skill frontmatter, architecture rules, etc.) without syntax errors.

Observed behaviour

All pre-commit hooks that use {files} placeholder fail with:

node: -c: line 3: syntax error: unexpected end of file

This happens because lefthook's file-passing mechanism on Windows/Git Bash generates invalid node -c command syntax.

Affected file(s)

  • lefthook.yml
  • scripts/pre-commit-all.sh

Steps to reproduce

  1. Clone the repository on Windows 10/11 with Git Bash
  2. Run make setup to install lefthook hooks
  3. Stage any file: git add .
  4. Attempt to commit: git commit -m "test"
  5. Observe the node syntax error for each hook

Environment

  • OS: Windows 10/11
  • Shell: Git Bash (mingw64)
  • Node.js: v22.12+ (as required by project)
  • lefthook: latest (installed via make setup)

Workarounds attempted

  1. Converted hooks to use "$@" instead of {files} — still fails with same syntax error
  2. Converted to stdin: true with $(cat) — still fails
  3. Created wrapper shell scripts — lefthook still invokes node -c with broken syntax
  4. Consolidated all checks into single all-checks command (current pre-commit-all.sh) — still times out/fails on Windows

Proposed solution direction

  • Option A: Document WSL2 as required environment for Windows contributors (simplest, aligns with Node.js tooling expectations)
  • Option B: Create Windows-compatible lefthook config using run: cmd //c ... or PowerShell wrappers
  • Option C: Move all pre-commit validation to CI-only (GitHub Actions) and rely on make check locally
  • Option D: Use a Node.js-based pre-commit runner (e.g., husky + lint-staged) that handles cross-platform file passing correctly

Additional context

The current pre-commit-all.sh script works correctly on Linux/WSL and validates:

  • JSON files (validate-json.mjs)
  • YAML files (validate-yaml.mjs)
  • Skill frontmatter (name:, description:)
  • Architecture rules (check-architecture-rules.js)
  • Skill argument hints
  • Context imports and reference form
  • Referenced paths
  • Doc duplication
  • Markdown links
  • Script tests

This is a blocker for Windows contributors who cannot use WSL2.

Activity

  1. blafourcade commented on Oct 6, 2026

    @blafourcade
    Contributor

    Validated as a Windows bug, but it is not limited to the {files} placeholder. Lefthook’s upstream issue #1167 reproduces the same Git Bash syntax error with multiline run blocks.

    This repository uses Lefthook 2.1.14, and releases through 2.1.17 do not list a fix. Also, scripts/pre-commit-all.sh is not present in the repository.

    The implementation should first reproduce the failure in the existing Windows CI job, then replace multiline shell blocks with single-line calls to a cross-platform Node runner while preserving the current checks. WSL-only and CI-only validation are not acceptable substitutes.

  2. added theissue type on Oct 6, 2026
  3. blafourcade commented on Oct 12, 2026

    @blafourcade
    Contributor

    Fixed by #998.

    The cause was double quotes, not multiline blocks. Lefthook on Windows runs each job as "sh.exe" -c "<script>" and escapes nothing, so a double quote followed by a space cut the script in two. A probe confirmed that a multiline run with no quote passes.

    No run in lefthook.yml holds a double quote any more, and a test enforces it. Two checks that also broke on Windows are fixed: CRLF line endings in check-skill-argument-hints, and the D:\D:\ path in sync-readme-counts. The cli / Windows job now runs a commit's hooks and fails if any hook fails.

    Validated on the Windows CI runner. No commit on a physical Windows machine yet; please reopen if one still fails.

    The same defect in the lefthook job that aidd telemetry on prints for users is tracked in #999.

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

    Fields

    Priority

    Medium

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions