question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

git commit fails to install environment in a git repo

See original GitHub issue

describe your issue

I added a .pre-commit-config.yml to an existing repo and committed it. Then I added some more files to the staging area and when I commit I get the prompt that pre-commit is creating an environment, but fails to install.

pre-commit --version

2.17.0

.pre-commit-config.yaml

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.1.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: check-added-large-files

~/.cache/pre-commit/pre-commit.log (if present)

version information

pre-commit version: 2.17.0
git --version: git version 2.35.1
sys.version:
    3.10.2 (main, Feb  2 2022, 06:19:27) [Clang 13.0.0 (clang-1300.0.29.3)]
sys.executable: /Users/luca/.local/pipx/venvs/pre-commit/bin/python
os.name: posix
sys.platform: darwin

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
Traceback (most recent call last):
  File "/Users/luca/.local/pipx/venvs/pre-commit/lib/python3.10/site-packages/pre_commit/error_handler.py", line 70, in error_handler
    yield
  File "/Users/luca/.local/pipx/venvs/pre-commit/lib/python3.10/site-packages/pre_commit/main.py", line 368, in main
    return hook_impl(
  File "/Users/luca/.local/pipx/venvs/pre-commit/lib/python3.10/site-packages/pre_commit/commands/hook_impl.py", line 237, in hook_impl
    return retv | run(config, store, ns)
  File "/Users/luca/.local/pipx/venvs/pre-commit/lib/python3.10/site-packages/pre_commit/commands/run.py", line 416, in run
    install_hook_envs(to_install, store)
  File "/Users/luca/.local/pipx/venvs/pre-commit/lib/python3.10/site-packages/pre_commit/repository.py", line 224, in install_hook_envs
    _hook_install(hook)
  File "/Users/luca/.local/pipx/venvs/pre-commit/lib/python3.10/site-packages/pre_commit/repository.py", line 86, in _hook_install
    raise AssertionError(
AssertionError: BUG: expected environment for python to be healthy() immediately after install, please open an issue describing your environment

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Feb 18, 2022

it’s definitely not isort’s problem, pipx makes the most sense

1reaction
asottilecommented, Feb 8, 2022

ah yep that would do it

you have a mix of 3.10.0, 3.10.1, and 3.10.2 – so when pre-commit creates a “python3.10” environment from 3.10.2 and gets an unrelated version it complains

you’ll want to clean up your python setup so you only reference one of those three versions and it should resolve itself – admittedly pipx should probably be detecting this case and healing for you but that would be a request towards pipx and not here

Read more comments on GitHub >

github_iconTop Results From Across the Web

pre-commit fails to install environment for Prettier #1393
pre-commit 2.2.0 fails during environment installation for Prettier 2.0.4, due to a dependency error raised by npm: npm ERR! code ETARGET ...
Read more >
pre-commit/hook: No such file or directory
Go to .git/hooks directory and remove pre-commit file, as its trying to reference to node_modules/pre-commit/hook . It should resolve it.
Read more >
Husky - Git hooks
Modern native git hooks made easy. Husky improves your commits and more woof! You can use it to lint your commit messages, run...
Read more >
How to use git pre-commit hooks, the hard way and the easy ...
How to write a git pre-commit hook (the hard way) ; #!/usr/bin/env bash # If any command fails, exit immediately with that command's...
Read more >
Git - git-init Documentation
Running git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found