{"record":{"id":"56d596907e630125","repo":"Graphify-Labs/graphify","slug":"no-git-repository-found-at-or-above-path-resolve","errorCode":null,"errorMessage":"No git repository found at or above {path.resolve()}","messagePattern":"No git repository found at or above (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"graphify/hooks.py","lineNumber":665,"sourceCode":"\ndef _user_hooks_dir(hooks_dir: Path) -> Path:\n    \"\"\"Return the user-editable hooks directory.\n\n    Husky 9 sets core.hooksPath to .husky/_ (wrapper scripts auto-generated by\n    Husky), while user-editable hooks live in the parent .husky/. Return the\n    parent when the resolved dir ends in '_' so install/status/uninstall target\n    the correct location (#987).\n    \"\"\"\n    if hooks_dir.name == \"_\":\n        return hooks_dir.parent\n    return hooks_dir\n\n\ndef install(path: Path = Path(\".\")) -> str:\n    \"\"\"Install graphify post-commit and post-checkout hooks in the nearest git repo.\"\"\"\n    root = _git_root(path)\n    if root is None:\n        raise RuntimeError(f\"No git repository found at or above {path.resolve()}\")\n\n    hooks_dir = _user_hooks_dir(_hooks_dir(root))\n\n    # Pin the current interpreter so the hook works even when the graphify\n    # launcher is not on PATH at git-trigger time (uv tool / pipx isolation).\n    # sys.executable is the Python running this very install command, so it is\n    # always the correct isolated-venv interpreter.  The placeholder is replaced\n    # in both scripts before writing; the allowlist in _pinned_python() strips\n    # any characters unsafe in a shell path (empty result -> the pinned probe is\n    # skipped), and import-verification catches a stale pinned path so it safely\n    # falls through to the dynamic detection.\n    pinned = _pinned_python()\n    hook = _HOOK_SCRIPT.replace(\"__PINNED_PYTHON__\", pinned)\n    checkout = _CHECKOUT_SCRIPT.replace(\"__PINNED_PYTHON__\", pinned)\n\n    commit_msg = _install_hook(hooks_dir, \"post-commit\", hook, _HOOK_MARKER)\n    checkout_msg = _install_hook(hooks_dir, \"post-checkout\", checkout, _CHECKOUT_MARKER)\n    merge_msg = _register_merge_driver(root)","sourceCodeStart":647,"sourceCodeEnd":683,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/hooks.py#L647-L683","documentation":"Raised by graphify's hooks install() when no .git directory can be found at or above the working path. Hook installation writes post-commit/post-checkout scripts into the repo's hooks directory (respecting core.hooksPath), so a git root is a hard prerequisite; _git_root returning None means the walk up from the given path never hit a repository boundary.","triggerScenarios":"Running `graphify hooks install` (default path '.') in a plain directory, a fresh project before `git init`, a subdirectory of an archive extract, or a path where .git was deleted; also when GIT_DIR semantics are unusual (worktree/submodule edge cases the walker doesn't recognize).","commonSituations":"Trying hooks in a scratch/docs folder; running the command from the wrong terminal cwd; sandboxed environments that strip .git; shallow automation clones that remove .git to save space.","solutions":["cd into the actual repository root (verify with `git rev-parse --show-toplevel`) and re-run","If the project isn't a repo yet: `git init` first, then `graphify hooks install`","Pass an explicit path inside the repo: `graphify hooks install /path/to/repo`"],"exampleFix":"# before\ncd ~/notes && graphify hooks install   # RuntimeError: No git repository found\n\n# after\ncd ~/myrepo && graphify hooks install","handlingStrategy":"validation","validationCode":"import subprocess\n\ndef inside_git_repo(path: str = \".\") -> bool:\n    return subprocess.run(\n        [\"git\", \"-C\", path, \"rev-parse\", \"--git-dir\"],\n        capture_output=True,\n    ).returncode == 0\n\nif not inside_git_repo():\n    raise SystemExit(\"not a git repository - run `git init` or cd to the repo root\")","typeGuard":null,"tryCatchPattern":"try:\n    install(Path(\".\"))\nexcept RuntimeError as e:\n    if \"No git repository found\" in str(e):\n        raise SystemExit(\"cd to a git repo, or `git init` first\")\n    raise","preventionTips":["Gate hook install steps in scripts on `git rev-parse --git-dir` succeeding","Run graphify hooks commands from the repo root in docs and CI","Don't strip .git from clones on machines where hooks must install"],"tags":["git","hooks","environment","cli"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}