fix(devshell): warn before pre-commit installer hits core.hooksPath block#31
Merged
Conversation
…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>
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.
Summary
Adds a 4-line guard in the dev
shellHook(inflake/dev-shell.nix) that detects a setcore.hooksPathand prints a clear actionable warning before pre-commit's installer fires.Why
Pre-commit refuses to install when
core.hooksPathis set, producing cryptic stderr twice per direnv activation:The root cause (global
core.hooksPathset 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 --getper direnv reload — no perceptible delay.Test plan
nix flake checkpassesdarwin-rebuild switch, freshcdproduces no warning and pre-commit installs cleanlygit config --local core.hooksPath .git/hooksthencd .triggers the warning with the unset-suggestion text visibleRefs: dryvist/nix-home#272