Skip to content

Use absolute binary path in git hooks for robustness#49

Closed
toothbrush wants to merge 6 commits intomainfrom
20260116-git-hook-absolute-path
Closed

Use absolute binary path in git hooks for robustness#49
toothbrush wants to merge 6 commits intomainfrom
20260116-git-hook-absolute-path

Conversation

@toothbrush
Copy link
Contributor

Description

Instead of assuming 'entire' is in PATH when git hooks execute, use os.Executable() to get the absolute path of the currently-running binary. This ensures hooks work correctly regardless of the user's PATH configuration at hook execution time.

The issue i was addressing here was that i like to run with go build ./cmd/entire && ./entire while doing local dev, rather than go run .... As a result Entire thinks it's running as "installed-globally mode", causing Git hooks to be incorrectly configured, and fail.

E.g.,

$ git … commit --
hint: Waiting for your editor to close the file...
.git/hooks/commit-msg: line 4: entire: command not found

If someone does globally install Entire, the absolute path should resolve to their $GOROOT or the Homebrew location or whatever. As another side-effect, if Git is used from within a GUI app that doesn't set a reasonable value for $PATH, the proposed approach will work better.

toothbrush and others added 5 commits January 16, 2026 11:18
Instead of assuming 'entire' is in PATH when git hooks execute,
use os.Executable() to get the absolute path of the currently-running
binary. This ensures hooks work correctly regardless of the user's
PATH configuration at hook execution time.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@toothbrush
Copy link
Contributor Author

I'm very open to input on this one – getting these sort of CLI tool ergonomics right is hard, because they need to work in all kinds of scenarios for people with all sorts of weird environments. I think this represents a reasonable improvement, but keen to hear what folks think.

Copy link
Collaborator

@Soph Soph left a comment

Choose a reason for hiding this comment

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

🙇

@Soph
Copy link
Collaborator

Soph commented Jan 16, 2026

Just realized something: the issue with the absolut path is that if you would commit that .claude/settings.json then, it would make the hooks not work on another machine since most likely the absolut path wouldn't be the same 🤔

@toothbrush
Copy link
Contributor Author

toothbrush commented Jan 16, 2026 via email

qiangmao pushed a commit to qiangmao/cli that referenced this pull request Feb 12, 2026
Like entirehq/entiredb#260.  I think this is a
better solution to the problem discussed in entireio/cli#49.
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