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.

update to Python 3.10, pre-commit fails

See original GitHub issue

describe your issue

Since I updated my Ubuntu 22.04 machine to Python 3.10, pre-commit gets in my way and I can’t figure out what to do. When trying to git commit on a Python project, pre-commit won’t let me with the error message

[INFO] Initializing environment for https://github.com/PyCQA/isort.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/PyCQA/flake8.
[INFO] Installing environment for https://github.com/PyCQA/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: AssertionError: BUG: expected environment for python to be healthy() immediately after install, please open an issue describing your environment
Check the log at /home/nschloe/.cache/pre-commit/pre-commit.log

See below for the log data.

I’m guessing there’s an old cache somewhere, but

pre-commit clean

didn’t help. Any other idea?

pre-commit --version

pre-commit 2.18.1

.pre-commit-config.yaml

repos:
  - repo: https://github.com/PyCQA/isort
    rev: 5.10.1
    hooks:
      - id: isort

  - repo: https://github.com/psf/black
    rev: 22.3.0
    hooks:
      - id: black
        language_version: python3

  - repo: https://github.com/PyCQA/flake8
    rev: 4.0.1
    hooks:
      - id: flake8

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

version information

pre-commit version: 2.18.1
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: /usr/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
Traceback (most recent call last):
  File "/home/nschloe/.local/lib/python3.10/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/home/nschloe/.local/lib/python3.10/site-packages/pre_commit/main.py", line 343, in main
    return hook_impl(
  File "/home/nschloe/.local/lib/python3.10/site-packages/pre_commit/commands/hook_impl.py", line 237, in hook_impl
    return retv | run(config, store, ns)
  File "/home/nschloe/.local/lib/python3.10/site-packages/pre_commit/commands/run.py", line 414, in run
    install_hook_envs(to_install, store)
  File "/home/nschloe/.local/lib/python3.10/site-packages/pre_commit/repository.py", line 221, in install_hook_envs
    _hook_install(hook)
  File "/home/nschloe/.local/lib/python3.10/site-packages/pre_commit/repository.py", line 83, 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 a year ago
  • Reactions:1
  • Comments:29 (15 by maintainers)

github_iconTop GitHub Comments

5reactions
asottilecommented, Apr 13, 2022
2reactions
asottilecommented, Apr 25, 2022

I don’t, personally I only care about ubuntu and the debian bug reporting process is a pain the ass so I didn’t bother and just contacted the devs directly (haven’t heard back)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment installation failing on python 3.10 #2139 - GitHub
If I make a fresh conda environment wiht python 3.10: mamba create -n test -c conda-forge python conda activate test pre-commit run --all- ......
Read more >
How to solve pre-commit asserttion error on ubuntu 22.04
This is a known issue with python 3.10 on Ubuntu 22.04, you can use the python 3.10 from deadsnakes as directed here.
Read more >
pre-commit
pip install pre-commit. In a python project, add the following to your requirements.txt (or requirements-dev.txt):. pre-commit. As a 0-dependency zipapp:.
Read more >
pre-commit.ci (@pre_commit_ci) / Twitter
[partial outage] some http://pre-commit.ci runs are not starting and stuck in the pending state due to a change on github's side -- will...
Read more >
pre-commit - PyPI
A framework for managing and maintaining multi-language pre-commit hooks.
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