Skip to content

fix(devshell): warn before pre-commit installer hits core.hooksPath block#31

Merged
JacobPEvans-personal merged 1 commit into
mainfrom
fix/hookspath-guard
May 31, 2026
Merged

fix(devshell): warn before pre-commit installer hits core.hooksPath block#31
JacobPEvans-personal merged 1 commit into
mainfrom
fix/hookspath-guard

Conversation

@JacobPEvans-personal
Copy link
Copy Markdown
Member

Summary

Adds a 4-line guard in the dev shellHook (in flake/dev-shell.nix) that detects a set core.hooksPath and prints a clear actionable warning before pre-commit's installer fires.

Why

Pre-commit refuses to install when core.hooksPath is set, producing cryptic stderr twice per direnv activation:

[ERROR] Cowardly refusing to install hooks with `core.hooksPath` set.
hint: `git config --unset-all core.hooksPath`

The root cause (global core.hooksPath set by home-manager) is being removed in dryvist/nix-home#272. This guard is defensive: if any future regression (global, local, or per-machine drift) sets the value again, the dev shell hands the user the actionable command (git config --unset core.hooksPath) instead of leaving them to decode the raw stderr.

Cost

If hooksPath is empty, it's a single git config --get per direnv reload — no perceptible delay.

Test plan

Refs: dryvist/nix-home#272

…lock

Pre-commit's installer refuses with "Cowardly refusing to install hooks
with core.hooksPath set" when any scope sets the value. The root cause
(global core.hooksPath in nix-home) is being removed in dryvist/nix-home#272,
but a defensive guard here surfaces a clear, actionable warning if any
future regression — global, local, or per-machine drift — sets the value
again. Without the guard the user sees the raw stderr twice per direnv
activation with no hint that the fix is `git config --unset core.hooksPath`.

The guard runs before installationScript; if hooksPath is empty it is a
single grep-and-exit, so no perceptible startup cost.

Refs: dryvist/nix-home#272

Assisted-by: Claude <noreply@anthropic.com>
@JacobPEvans-personal JacobPEvans-personal merged commit 9fc82a2 into main May 31, 2026
4 checks passed
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.

1 participant