Skip to content

bug: pnpm lint hook rewrite defaults to ESLint; "command not found" (exit 254) misreported as "possibly out of memory" #2879

Open

Description

@linustalacko

Summary

Companion issue to #2878 (same class of bug — rtk output-filtering silently hides real failures — found and verified together; unrelated code path so filed separately).

When a project's lint script doesn't use ESLint (e.g. it's just prettier --check .) and ESLint isn't installed, the hook rewrite engine still rewrites pnpm lint → rtk lint, which defaults to ESLint, fails to resolve the binary, and prints a misleading [warn] Linter process terminated abnormally (possibly out of memory) instead of any indication that ESLint was never the right tool at all. Confirmed on rtk 0.43.0 (Homebrew, macOS arm64), reproduced both from a clean source clone and against the installed binary.

This shares its "defaults to ESLint" root cause with #665, #1489, #2094 and #2832, but the specific failure mode here — pnpm's "command not found" exit code getting reinterpreted as a signal-death/OOM warning — doesn't appear to be covered by any of them (searched for "possibly out of memory", "terminated abnormally", "254"; no matching issues).

Root cause (verified against the v0.43.0 tag, commit 5a7880d)

  1. src/discover/rules.rs:153 — the rewrite rule ^(...)?(biome|eslint|lint)(\s|$) maps any command/script literally named lint to rtk lint, with "pnpm lint" listed verbatim in rewrite_prefixes (line 187). This fires regardless of what the lint script actually runs. Confirmed via the repo's own test_rewrite_lint (src/discover/registry.rs:2677), which asserts "pnpm lint" rewrites to Some("rtk lint") — passes on this tag (cargo test test_rewrite_lint → ok).

  2. src/cmds/js/lint_cmd.rs:77-88 — detect_linter() receives no linter name (the rewrite produced bare rtk lint, no args), so args.is_empty() is true and it defaults to ("eslint", false) at line 84.

  3. src/cmds/js/lint_cmd.rs:173-174 — rtk lint then runs pnpm exec eslint .. When eslint isn't an installed dependency, pnpm exits 254 with ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command "eslint" not found. lint_cmd's exit_code > 128 check treats this as "process killed by signal" and prints [warn] Linter process terminated abnormally (possibly out of memory) — a false and actively misleading diagnosis; nothing was killed, pnpm simply couldn't resolve the binary and exited normally with a non-zero code.

Repro (verified live against the installed rtk 0.43.0 binary)

package.json (no ESLint dependency anywhere):

{ "scripts": { "lint": "prettier --check ." }, "devDependencies": { "prettier": "^3.3.0" } }
$ pnpm exec eslint .; echo "exit=$?"
undefined
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command "eslint" not found
exit=254

$ rtk lint; echo "exit=$?"
[warn] Linter process terminated abnormally (possibly out of memory)
exit=254

(rtk lint here stands in for what the hook produces. With the config-level workaround described below removed, rtk hook check "pnpm lint" on a stock config rewrites to exactly this, and test_rewrite_lint confirms "pnpm lint" → rtk lint is the intended stock behavior.)

An agent seeing "possibly out of memory" has no reason to suspect the real problem (wrong linter entirely) and will typically retry, chase memory/resource limits, or otherwise pursue the wrong root cause.

Environment

  • rtk 0.43.0, Homebrew install, macOS arm64
  • pnpm 10.22.0, Node v22.23.1, no ESLint installed, prettier 3.9.4 as the actual lint script

Suggested fix

Any of:

  1. Don't rewrite pnpm lint / npm run lint / etc. at all — these names point at a project-defined script body the hook can't see (also suggested as option 1 in bug: hook rewrite of pnpm lint discards package.json script body — same false-green as #185 at the hook layer #2094).
  2. Resolve the script body from package.json before rewriting/dispatching, and only route to the ESLint adapter when it actually invokes eslint (or biome/ruff/whatever the project really uses).
  3. At minimum, stop classifying pnpm/npm "command not found" exit codes (254 for pnpm) as > 128 signal-death — detect the specific "not found" / ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL signature and report "eslint is not installed" instead of "possibly out of memory".

Local workaround

Hook-level exclusion in config.toml (mirrors the rewrite rule in src/discover/rules.rs, not a general fix — just stops rtk intercepting anything literally named lint at the hook layer; typing rtk lint explicitly is unaffected and works fine when ESLint really is the project's linter):

[hooks]
exclude_commands = [
    '^((p?np(m|x)|p?npm\s+(exec|run|run-script)|npm\s+(rum|urn|x)|pnpm\s+dlx)\s+)?lint(\s|$)',
]

Activity

  1. added
    bug
    help wanted
    on Jul 8, 2026
  2. pszymkowiak commented on Jul 8, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 90%

    Summary

    pnpm lint hook rewrite defaults to ESLint even when the project's lint script isn't ESLint, and misclassifies pnpm's exit 254 'command not found' as a signal-death OOM warning, actively misleading agents/users about the real problem.

    📁 Relevant files
    • src/discover/rules.rs
    • src/cmds/js/lint_cmd.rs
    • src/discover/registry.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. tianhuil commented on Nov 17, 2026

    @tianhuil

    Same on rtk 0.45.0, Linux x86_64, pnpm 10.15.0, Biome 2.6.4. pnpm exec biome --version is rewritten too (to rtk lint --version), so even a version check prints the out-of-memory warning; it sent our agents chasing memory pressure for weeks.

    Workaround that also holds for chained and env-prefixed commands (cd x && pnpm lint, FOO=1 pnpm lint), checked with rtk rewrite:

    [hooks]
    exclude_commands = [
        "^((p?npx|pnpm|npm|bunx)( (exec|run|run-script|dlx))? )?biome( |$)",
        "^(pnpm|npm)( (run|run-script))? lint( |$)",
    ]
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

    area:clibughelp wantedpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions