fix(hooks): pre-commit fell open when pnpm was missing from PATH#2753
Open
sturdy4days wants to merge 1 commit into
Open
fix(hooks): pre-commit fell open when pnpm was missing from PATH#2753sturdy4days wants to merge 1 commit into
sturdy4days wants to merge 1 commit into
Conversation
The hook ran `pnpm run format:fix` and ignored its exit status, so on a shell whose PATH lacks pnpm (common when pnpm is a corepack shim inside the Node prefix and the user commits from a plain login shell) the hook printed "pnpm: command not found" and the commit proceeded with the formatter silently skipped. Resolve pnpm explicitly (corepack fallback) and fail closed: a missing or failing formatter now blocks the commit with a clear message instead of skipping. Deliberate bypass stays available via git commit --no-verify.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
.claude/skills/<name>/, no source changes)Description
What: The pre-commit hook fails closed instead of open when pnpm can't run.
Why: The hook ran
pnpm run format:fixand ignored its exit status. On a shell whose PATH lacks pnpm — common when pnpm is a corepack shim inside the Node prefix and the user commits from a plain login shell or GUI client — the hook printedpnpm: command not foundand the commit proceeded anyway, with formatting silently skipped. A hook that fails open is worse than no hook: you believe the check ran. Observed live on a corepack-shim install (the formatter had been silently skipping for weeks of commits).How it works: Resolve pnpm explicitly (
command -v pnpm, falling back tocorepack pnpm); if neither is available, orformat:fixitself fails, block the commit with a clear message. Deliberate bypass stays available viagit commit --no-verify.How it was tested: All three branches exercised with controlled PATHs: pnpm present (runs directly), corepack only (runs via shim), neither (commit blocked with the message, exit 1). Also verified end-to-end on a real install where the old hook reproducibly fell open from a login shell.
🤖 Generated with Claude Code