Skip to content

install writes a machine-absolute binary path into repo-tracked .codex/hooks.json (breaks other machines; emit PATH-based command) #3129

Open
bauer-automate/3P-graphify
#13

Description

@yotamleo

Summary

graphify install (0.9.50, Windows, uv tool install) writes a machine-absolute binary path into the repo-tracked Codex hooks file .codex/hooks.json:

{
  "hooks": [
    { "command": "C:/Users/<user>/.local/bin/graphify.EXE hook-check", "type": "command" }
  ],
  "matcher": "Bash"
}

Why this is a problem

.codex/hooks.json is a repo-tracked, shared file (unlike per-user config). Committing the installer's output therefore:

  1. Breaks every other machine/collaborator — the absolute path (C:/Users/<user>/..., the uv tool shim location) does not exist elsewhere; on machines without graphify the hook errors on every Bash tool call in Codex sessions.
  2. Churns the file per machine — each machine that runs graphify install rewrites the entry with its local path, producing endless diffs in a shared enforcement file.
  3. There is no fail-open guard: the command is invoked directly, so a missing binary is a hard hook failure rather than a no-op.

Suggested fix

  • Emit a PATH-based command (graphify hook-check) — the uv shim directory is on PATH in the environments where install succeeds — or make the command template configurable.
  • Optionally wrap with an existence guard so machines without graphify fail open (skip) instead of erroring.

Environment

  • graphify 0.9.50 (graphifyy from PyPI, uv tool install --with mcp)
  • Windows 11, Codex CLI 0.149.1
  • Observed after graphify install refreshed harness integration files (.codex/hooks.json, AGENTS.md, GEMINI.md)

Activity

  1. davidbhoward commented on Aug 27, 2026

    @davidbhoward
    Contributor

    This is the same thing for Claude Code.

    graphify install The only debate I think maintainers might have here with this is that the installation is not for a project. It is not really expected that other people will also be maintaining that same location. Whereas, if you use the --project, you will get this same problem but with the expectation that others will also be contributing to that project.

  2. safishamsi commented on Aug 29, 2026

    @safishamsi
    Member

    Partially addressed in v0.9.52 (#3149): a graphify install --project (committed/shared) install now emits a bare, run-time-resolved hook command instead of pinning an absolute interpreter path, so the committed hook no longer churns across machines. The plain (non---project) install-into-cwd case is entangled with #2164 and left for a follow-up, so leaving this open. Fixed in v0.9.52: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.52

  3. davidbhoward commented on Aug 29, 2026

    @davidbhoward
    Contributor

    This sounds great. Thank you so much for all your work.

  4. yotamleo commented on Sep 1, 2026

    @yotamleo
    ContributorAuthor

    Thanks for the v0.9.52 fix — confirming it from the current v8, and narrowing what is left, since the remaining case is the default one.

    _install_codex_hook() writes to project_dir / ".codex" / "hooks.json" unconditionally, and project_dir defaults to Path(".") — so the file is inside the repo on every install, not only on --project ones. What the flag changes is the command written into it:

    def _resolve_graphify_exe(project: bool = False) -> str:
        import shutil
        if project:
            return "graphify"
        found = shutil.which("graphify")
        if not found:
            scripts_dir = Path(sys.executable).parent
            for name in ("graphify.exe", "graphify"):
                candidate = scripts_dir / name
                if candidate.exists():
                    found = str(candidate)
                    break
        return (found or "graphify").replace("\\", "/")

    So with --project the hook is now the portable bare graphify hook-check — fixed, as you said. Without it, the same repo-tracked .codex/hooks.json still receives the absolute shutil.which/sys.executable-derived path, which is the original failure: commit it, and it breaks for every other machine and CI, since that path does not exist there.

    That leaves the bug fully reproducible on the default install path, which is the one most people will hit — graphify install . without --project. Agreed it should stay open.

    Two options, whichever fits your intent better:

    1. Emit the bare command whenever the destination is repo-tracked — i.e. make the .codex/hooks.json writer always use "graphify", since that file is committed by definition. The absolute path only ever helps a graphify that is not on PATH, and in that case a committed hook would be wrong on the author's machine too as soon as the venv moves.
    2. Keep the absolute path but stop writing it to a tracked location for non-project installs.

    Happy to send a patch for whichever you prefer — (1) is a one-line change at the call site. Not opening a PR unless you want it, so as not to collide with anything you already have in flight.

  5. yotamleo commented on Sep 1, 2026

    @yotamleo
    ContributorAuthor

    Sent the patch I offered above as #3268 — option (1), and easy to close if you'd rather have (2) or neither. You deferred this half deliberately, so I've tried to make it cheap to reject rather than argue you out of the deferral.

    One thing I found while building it that changes the picture slightly, and it's the reason the PR is a little wider than "one line at the call site" as I estimated:

    The same defect is in the claude, gemini and codebuddy hook writers, not just codex. _install_claude_hook, _install_gemini_hook and _install_codex_hook all resolve their destination as project_dir / ".<tool>" with the caller passing project_dir or Path(".") — so every one of them writes into the working directory whether or not --project was given. _claude_pretooluse_hooks is shared by claude and codebuddy, and codebuddy has no --project variant at all, so every codebuddy install has been writing an absolute path into a repo-tracked file.

    Since it's one root cause behind four platforms, fixing only the codex path the issue names would have left the siblings broken, so the PR fixes it in the three shared resolvers instead.

    This does contradict a premise in #3149, and I'd rather say so up front than have you find it: that PR kept the absolute path for the non-project install on the grounds that it targets "a location others are not expected to share." For these particular hook files there is no such location — they always land in the cwd. So the test it added to pin that behaviour (test_user_profile_install_still_resolves_absolute_path) was pinning a premise that doesn't hold for them. I replaced rather than quietly edited it, with a docstring saying why.

    The real cost is stated in the PR: _resolve_graphify_exe's docstring notes the absolute path is what makes the hook work where the venv Scripts/ dir isn't on PATH (VS Code Codex extension on Windows). This gives that up. I think #3149's own "a missing binary and a wrong absolute path both fail; the difference is diagnosis" argument covers it — that argument was scoped to "the committed case," and for these files every case turns out to be the committed case — but that's a judgment you may weigh differently, and it's the one I'd push back on if I were reviewing.

    Still deliberately not touching #2164's question of where these files should go; the PR only changes what goes inside them at today's destination.

  6. omsenjalia commented on Oct 18, 2026

    @omsenjalia
    Contributor

    This looks fixed on the v8 branch by 35c63493 (fix(install): emit a bare hook command for project-scoped installs (#3129)). Could a maintainer confirm and close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions