You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Different cwd compared to pre-commit when installing additional_deps of repo: localΒ #1603
The behavior of repo: local between pre-commit and prek is different
In prek, the cwd during virtualenv installation of repo: local is the current repo.
In pre-commit, the cwd during virtualenv installation of repo: local is a pseudo repo.
For repo: local,
The pre-commit creates pseudo directory inside ~/.cache/pre-commit,
with pseduo setup scripts, such as setup.py
from setuptools import setup
setup(name='pre-commit-placeholder-package', version='0.0.0', py_modules=[])
During the installation of virtualenv, the cwd is inside that pseudo directory,
so that specify . in additional_dependencies does not work in the same way as many people expected,
and so specify python extra dependencies like .[foo] does not work either.
I think this is a good design of pre-commit that should be maintained,
that need to ensure additional_dependencies: does not depend on the content of local repository,
otherwise it is not safe to reuse the cached virtualenv, as the content of local repository may change.
Platform
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 GNU/Linux
changed the title [-]Different cwd compared to `pre-commit` when installing addidtional_deps of `repo: local`[/-][+]Different cwd compared to `pre-commit` when installing additional_deps of `repo: local`[/+]on Feb 8, 2026
This behaviour is not documented.
I find quite confusing that pre-commit behaves this way.
Is the only reason for this confusing behaviour of pre-commit reusing the cached virtualenv?
If this is the case, could we not simply not cache the venv for local hooks but instead recreate it every run?
As prek is using uv under the hood this should reduce the speed only minimal.
uv already caches packages and only harldinks the their files if possible.
Only overhead would be dependency resolution which is quite fast as well.
Doing that prek would behave more like users would expect it.
Activity
[-]Different cwd compared to `pre-commit` when installing addidtional_deps of `repo: local`[/-][+]Different cwd compared to `pre-commit` when installing additional_deps of `repo: local`[/+]fix: preserve additional_dependencies order and use synthetic local repo
fix: preserve additional_dependencies order and use synthetic local repo
fix: preserve additional_dependencies order and use synthetic local repo
CarliJoy commentedon Mar 12, 2026
This behaviour is not documented.
I find quite confusing that pre-commit behaves this way.
Is the only reason for this confusing behaviour of pre-commit reusing the cached virtualenv?
If this is the case, could we not simply not cache the venv for local hooks but instead recreate it every run?
As prek is using uv under the hood this should reduce the speed only minimal.
uv already caches packages and only harldinks the their files if possible.
Only overhead would be dependency resolution which is quite fast as well.
Doing that
prekwould behave more like users would expect it.Preserve additional dependency order (#2311)