Skip to content

fix(enable): explain core.hooksPath when hooks dir is not a directory - #1851

Merged
gtrrz-victor merged 3 commits into
mainfrom
fix/hookspath-devnull-error
Jul 27, 2026
Merged

fix(enable): explain core.hooksPath when hooks dir is not a directory#1851
gtrrz-victor merged 3 commits into
mainfrom
fix/hookspath-devnull-error

Conversation

@peyton-alt

@peyton-alt peyton-alt commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/937

Problem

A user reported entire enable "crashing" with:

failed to install git hooks: failed to create hooks directory: mkdir /dev/null: not a directory

The cause is core.hooksPath = /dev/null in their git config — a common idiom for globally disabling git hooks (e.g. to neuter Husky). GetHooksDir resolves the hooks dir via git rev-parse --git-path hooks, which faithfully returns /dev/null, and os.MkdirAll then fails with a raw OS error. The message says what failed but never mentions core.hooksPath, so users can't connect it to their own config and report it as a bug.

Fix

Before MkdirAll, stat the resolved hooks path; if it exists and is not a directory, fail with guidance:

failed to install git hooks: git resolves the hooks directory to /dev/null, which is not a directory — core.hooksPath is likely set to disable git hooks
Entire requires git hooks to capture sessions. See where it is set with:
  git config --show-origin --get-all core.hooksPath
then unset it (git config --global --unset core.hooksPath) or override for this repo (git config core.hooksPath .git/hooks) and re-run 'entire enable'

Testing

  • New TestInstallGitHook_HooksPathNotADirectory (uses /dev/null on Unix, a regular file on Windows); watched it fail on the old behavior first
  • mise run fmt, mise run lint, mise run test (8302 tests) all green

🤖 Generated with Claude Code


Note

Low Risk
Small, pre-install validation and clearer errors only; no change to successful hook installation paths.

Overview
When entire enable installs git hooks, it now detects a resolved hooks path that exists but is not a directory (e.g. core.hooksPath = /dev/null) before MkdirAll, instead of surfacing a generic mkdir … not a directory error.

Users get an error that names core.hooksPath, shows the resolved path, and suggests git config --show-origin --get-all core.hooksPath plus unset or repo-local override before re-running entire enable.

Coverage is added in TestInstallGitHook_HooksPathNotADirectory (/dev/null on Unix, a file path on Windows).

Reviewed by Cursor Bugbot for commit 07ce70c. Configure here.

When core.hooksPath points at a non-directory (commonly /dev/null, the
idiom for globally disabling git hooks), 'entire enable' failed with a
raw 'mkdir /dev/null: not a directory' error that users read as a
crash. Detect the case before MkdirAll and return guidance naming
core.hooksPath, how to find where it is set, and how to unset or
override it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@peyton-alt
peyton-alt requested a review from a team as a code owner July 24, 2026 15:04
Copilot AI review requested due to automatic review settings July 24, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the entire enable hook-install path by detecting when Git resolves the hooks directory to a non-directory (e.g. core.hooksPath=/dev/null) and returning a targeted, actionable error instead of a raw mkdir ... not a directory failure.

Changes:

  • Add a pre-MkdirAll os.Stat guard in InstallGitHook to detect a non-directory hooks path and return guidance mentioning core.hooksPath.
  • Add a new test covering the “hooks path is not a directory” scenario, including a Windows-specific setup path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/strategy/hooks.go Adds a guard to produce a clearer error when the resolved hooks path exists but is not a directory.
cmd/entire/cli/strategy/hooks_test.go Adds regression coverage for the non-directory hooks-path case (Unix /dev/null, Windows regular file).

Comment thread cmd/entire/cli/strategy/hooks_test.go
peyton-alt and others added 2 commits July 24, 2026 11:38
…oundary

Review follow-ups: core.hooksPath pointing below a non-directory
(/dev/null/hooks) stat-fails with ENOTDIR and skipped the guidance;
extend the guard to cover it. Add a boundary test proving a
configured-but-missing hooks path still gets created by MkdirAll.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…alue

Copilot review follow-up: the error prints the path resolved via
git rev-parse --git-path hooks, which may normalize separators on
Windows; assert against GetHooksDir's result so the test matches what
the error actually contains.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gtrrz-victor
gtrrz-victor merged commit 23ebcc5 into main Jul 27, 2026
11 checks passed
@gtrrz-victor
gtrrz-victor deleted the fix/hookspath-devnull-error branch July 27, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants