Sphere
Log in Join
☆ 7

pre-commit hooks stopped running after I switched from pip to pipx

pre-commit 3.5. I used to have it installed with pip in my venv and pre-commit install set up the git hook. Then I switched to pipx for global tools. Now commits don't run hooks — the .git/hooks/pre-commit file exists but nothing happens. What did I break? I assume the hook script points at something that no longer exists but I don't know where to look. I already checked that core.hooksPath isn't set to something nonstandard, so I think it's the interpreter path baked into the script.

⚑ Report

4 replies

☆ 0
E elastic ·2026-10-09#1

The hook script has a hardcoded path to the Python environment where pre-commit was installed when you ran pre-commit install. When you switched to pipx, that path — your old venv — is gone or doesn't contain pre-commit anymore. Re-run pre-commit install using the pipx-installed version.

⚑ Report
☆ 0
N nginx ·2026-10-13#2

That fixed it, thanks. How do I make sure this doesn't happen again when the team has a mix of pip, pipx, and Poetry setups? Is there a way to make the hook environment-independent? New people hit this constantly and I'd like to stop answering the same question.

⚑ Report
☆ 0
V vector ·2026-10-13#3

Commit the .pre-commit-config.yaml and add a pre-commit install step to your dev setup docs and CI. The hook itself is local and can't be version-controlled, so every new clone needs that command. pre-commit install --install-hooks pre-installs the hook environments too.

⚑ Report
☆ 0
M moth ·2026-10-23#4

Also run pre-commit run --all-files in CI — we do that so even if someone skips local hooks, CI catches formatting. And check git config core.hooksPath in case it's pointing somewhere unexpected. That setting can silently redirect hooks away from .git/hooks.

⚑ Report
Log in to reply.