Skip to content

fix(exec): expose lefthook binary on PATH for nested hook commands - #1519

Open
rwinkelman wants to merge 2 commits into
evilmartians:masterfrom
rwinkelman:fix/nested-lefthook-path-1518
Open

fix(exec): expose lefthook binary on PATH for nested hook commands#1519
rwinkelman wants to merge 2 commits into
evilmartians:masterfrom
rwinkelman:fix/nested-lefthook-path-1518

Conversation

@rwinkelman

Copy link
Copy Markdown

Summary

  • When git invokes hooks (especially pre-push), the environment often has a stripped PATH
  • Nested jobs like run: lefthook validate then fail with sh: lefthook: command not found even though the parent process is lefthook
  • Prepend the running binary's directory to PATH and set LEFTHOOK_BIN for every job command

Fixes #1518

Test plan

  • Unit tests for withLefthookEnv (env_test.go)
  • CI go test ./internal/run/controller/exec/...

Git push hooks often run with a stripped PATH, so jobs like `run: lefthook validate` fail even though the parent lefthook process is running. Prepend the running binary's directory to PATH and set LEFTHOOK_BIN for child commands.

Fixes evilmartians#1518
@rwinkelman
rwinkelman requested a review from mrexox as a code owner August 31, 2026 13:22
@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (2): Last reviewed commit: "fix(exec): warn when lefthook PATH enric..." | Re-trigger Greptile

Comment thread internal/run/controller/exec/env.go Outdated
Comment thread internal/run/controller/exec/env_test.go Outdated
Log executable/symlink resolution failures instead of silently skipping
PATH enrichment, and refactor env tests to the table-driven convention.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lefthook not found when called with push hook command

1 participant