giticket
giticket copied to clipboard
Hook does not work with venv and python 3.10.4
Hook does not work with venv
and python
3.10.4.
version information
pre-commit version: 2.19.0
git --version: git version 2.34.1
sys.version:
3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0]
sys.executable: /home/***/env/bin/python3
os.name: posix
sys.platform: linux
error information
An unexpected error has occurred: AssertionError: BUG: expected environment for python to be healthy immediately after install, please open an issue describing your environment
more info:
virtualenv python version did not match created version:
- actual version: <<error retrieving version from /home/hadi/.cache/pre-commit/repoaviv15vw/py_env-python3/bin/python>>
- expected version: 3.10.4.final.0
Traceback (most recent call last):
File "/home/***/env/lib/python3.10/site-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File "/home/***/env/lib/python3.10/site-packages/pre_commit/main.py", line 361, in main
return hook_impl(
File "/home/***/env/lib/python3.10/site-packages/pre_commit/commands/hook_impl.py", line 238, in hook_impl
return retv | run(config, store, ns)
File "/home/***/env/lib/python3.10/site-packages/pre_commit/commands/run.py", line 414, in run
install_hook_envs(to_install, store)
File "/home/***/env/lib/python3.10/site-packages/pre_commit/repository.py", line 223, in install_hook_envs
_hook_install(hook)
File "/home/***/env/lib/python3.10/site-packages/pre_commit/repository.py", line 84, in _hook_install
raise AssertionError(
AssertionError: BUG: expected environment for python to be healthy immediately after install, please open an issue describing your environment
more info:
virtualenv python version did not match created version:
- actual version: <<error retrieving version from /home/***/.cache/pre-commit/repoaviv15vw/py_env-python3/bin/python>>
- expected version: 3.10.4.final.0
Possible Fix
This hot fix fixes the problem for me.
--- languages/python.py 2022-07-04 21:53:03.152943042 +0430
+++ languages/python.py 2022-07-04 21:52:59.832929712 +0430
@@ -50,6 +50,7 @@
def bin_dir(venv: str) -> str:
"""On windows there's a different directory for the virtualenv"""
bin_part = 'Scripts' if os.name == 'nt' else 'bin'
+ venv = os.path.join(venv, "local")
return os.path.join(venv, bin_part)
@hadisfr thanks for opening an issue. Is the fix suggested above, aimed towards virtualenv repo?
@milind-shakya-sp Yes it was aiming to handle python virtualenv.
(I supposed I had responded to this thread weeks ago, but it seems that my response did not being sent. So here we go.)