Skip to content

lefthook (sometimes) detects the wrong git directory when installed via uv #1399

@nihalgonsalves

Description

@nihalgonsalves

Description

This seems limited to the way uv installs/caches dependencies in certain cases, but lefthook will detect the wrong git root.

lefthook.yml

Not relevant

Commands to reproduce

$ pwd
/Users/nihalgonsalves/Developer/actual-git-repo
$ uv run lefthook install
│  [lefthook] git: git version
│             out: git version 2.53.0
│  [lefthook] git: git rev-parse --path-format=absolute --show-toplevel --git-path hooks --git-path info --git-dir
│             out: /Users/nihalgonsalves/.cache/uv/git-v0/db/001c65abee8f6b9f
│                  /Users/nihalgonsalves/Developer/actual-git-repo/.git/hooks
│                  /Users/nihalgonsalves/Developer/actual-git-repo/.git/info
│                  /Users/nihalgonsalves/Developer/actual-git-repo/.git
│  [lefthook] git: git config --local core.hooksPath
│  [lefthook] git: git config --global core.hooksPath
│  config dir: /Users/nihalgonsalves/.cache/uv/git-v0/db/001c65abee8f6b9f
│  loading config: /Users/nihalgonsalves/.cache/uv/git-v0/db/001c65abee8f6b9f/lefthook.yml
sync hooks: ✔️

(The config exists because I ran uv run lefthook install and it created it in that directory, the problem is the config dir detection itself)

It doesn't matter if it's run via uv run lefthook, directly (.venv/bin/lefthook install) / or within the venv (after activation).

I assume that the git-v0 directory is not always present or linked to the local venv / directory, so it doesn't always fail.

Lefthook version

2.1.4

Possible solution

Ignore .cache/uv git directories or configure the precedence of reading the git directory differently?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions