pre-commit: An unexpected error has occurred: AssertionError: BUG: expected environment for python to be healthy() immediately after install, please open an issue describing your environment

describe your issue

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 /Users/duanjiaxing/.cache/pre-commit/pre-commit.log

pre-commit --version

pre-commit 2.17.0

.pre-commit-config.yaml

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.3.0
    hooks:
      - id: check-yaml
        args: [--allow-multiple-documents]
      - id: end-of-file-fixer
      - id: trailing-whitespace
  - repo: https://github.com/golangci/golangci-lint
    rev: v1.33.0
    hooks:
      - id: golangci-lint

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

version information

pre-commit version: 2.17.0
git --version: git version 2.30.0
sys.version:
    3.10.2 (main, Feb  2 2022, 06:19:27) [Clang 13.0.0 (clang-1300.0.29.3)]
sys.executable: /usr/local/Cellar/pre-commit/2.17.0/libexec/bin/python3.10
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 "/usr/local/Cellar/pre-commit/2.17.0/libexec/lib/python3.10/site-packages/pre_commit/error_handler.py", line 70, in error_handler
    yield
  File "/usr/local/Cellar/pre-commit/2.17.0/libexec/lib/python3.10/site-packages/pre_commit/main.py", line 378, in main
    return install(
  File "/usr/local/Cellar/pre-commit/2.17.0/libexec/lib/python3.10/site-packages/pre_commit/commands/install_uninstall.py", line 128, in install
    install_hooks(config_file, store)
  File "/usr/local/Cellar/pre-commit/2.17.0/libexec/lib/python3.10/site-packages/pre_commit/commands/install_uninstall.py", line 134, in install_hooks
    install_hook_envs(all_hooks(load_config(config_file), store), store)
  File "/usr/local/Cellar/pre-commit/2.17.0/libexec/lib/python3.10/site-packages/pre_commit/repository.py", line 224, in install_hook_envs
    _hook_install(hook)
  File "/usr/local/Cellar/pre-commit/2.17.0/libexec/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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 15 (6 by maintainers)

Most upvoted comments

cd /usr/local/Cellar/pre-commit/2.17.0/libexec/bin/ and then exec virtualenv --reset-app-data vvv -vvvv --without-pip --clear can fix it.

@absassi I tried executing python3.10 -m virtualenv vvv with many versions of virtualenv but none got the directory you want. vvv/bin directory does not exist If it’s a virtualenv problem, the previous version should be ok

you’ve got the wrong commands – you should be able to copy paste the commands and then copy paste their output

screenshots of text are:

  1. unsearchable
  2. inaccessible