Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zhijian-pro opened this issue Mar 4, 2022 · 15 comments

Comments

@zhijian-pro
Copy link

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
@zhijian-pro
Copy link
Author

This problem appeared after brew update

@zhijian-pro
Copy link
Author

image

@asottile
Copy link
Member

asottile commented Mar 4, 2022

can you try the following for me?

/usr/local/Cellar/pre-commit/2.17.0/libexec/bin/python3.10 --version --version
/usr/local/Cellar/pre-commit/2.17.0/libexec/bin/python3.10 -m virtualenv vvv
vvv/bin/python3 --version --version
cat vvv/pyvenv.cfg

@zhijian-pro
Copy link
Author

image

@asottile

@asottile
Copy link
Member

asottile commented Mar 4, 2022

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

@zhijian-pro
Copy link
Author

zhijian-pro commented Mar 4, 2022

 ~  /usr/local/Cellar/pre-commit/2.17.0/libexec/bin/python3.10 --version --version

Python 3.10.2 (main, Feb  2 2022, 06:19:27) [Clang 13.0.0 (clang-1300.0.29.3)]
 ~  /usr/local/Cellar/pre-commit/2.17.0/libexec/bin/python3.10 -m virtualenv vvv

created virtual environment CPython3.10.2.final.0-64 in 416ms
  creator CPython3Posix(dest=/Users/duanjiaxing/vvv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/duanjiaxing/Library/Application Support/virtualenv)
    added seed packages: pip==22.0.3, setuptools==60.7.1, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
 ~  /vvv/bin/python3 --version --version

zsh: no such file or directory: /vvv/bin/python3
 ✘  ~  vvv/bin/python3 --version --version

zsh: no such file or directory: vvv/bin/python3
 ✘  ~  cat vvv/pyvenv.cfg

home = /usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10
implementation = CPython
version_info = 3.10.2.final.0
virtualenv = 20.13.0
include-system-site-packages = false
base-prefix = /usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10
base-exec-prefix = /usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10
base-executable = /usr/local/opt/python@3.10/bin/python3.10

@zhijian-pro
Copy link
Author

vvv/bin/python3 --version --version
It is indeed wrong for me to execute this command locally, you may have made a mistake in the directory structure in vvv

@asottile
Copy link
Member

asottile commented Mar 4, 2022

if it's missing vvv/bin/python3 that's certainly a problem. can you show what's inside vvv and vvv/bin ?

also wrap your outputs in triple backticks so they're readable: `

@zhijian-pro
Copy link
Author

cd vvv
tree -L 5
.
├── lib
│   └── python3.10
├── pyvenv.cfg
└── usr
    └── local
        ├── bin
        │   ├── activate
        │   ├── activate.csh
        │   ├── activate.fish
        │   ├── activate.nu
        │   ├── activate.ps1
        │   ├── activate_this.py
        │   ├── deactivate.nu
        │   ├── pip
        │   ├── pip-3.10
        │   ├── pip3
        │   ├── pip3.10
        │   ├── python -> /usr/local/opt/python@3.10/bin/python3.10
        │   ├── python3 -> python
        │   ├── python3.10 -> python
        │   ├── wheel
        │   ├── wheel-3.10
        │   ├── wheel3
        │   └── wheel3.10
        └── lib
            └── python3.10
                └── site-packages

8 directories, 19 files

@asottile
Copy link
Member

asottile commented Mar 4, 2022

that looks like a bug in virtualenv then -- please report it to https://github.com/pypa/virtualenv

@zhijian-pro
Copy link
Author

zhijian-pro commented Mar 8, 2022

@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

@asottile
Copy link
Member

asottile commented Mar 8, 2022

please report a bug at that link so it can be fixed!

@zhijian-pro
Copy link
Author

zhijian-pro commented Mar 9, 2022

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.

@Doris-Ye
Copy link

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.

Cannot work for me

$ virtualenv --reset-app-data vvv -vvvv --without-pip --clear
56 setup logging to NOTSET [DEBUG report:35]
57 reset app data folder C:/Users/23203/AppData/Local/pypa/virtualenv [DEBUG via_disk_folder:57]
274 find interpreter for spec PythonSpec(path=C:/msys64/mingw64/bin/python.exe) [INFO builtin:56]
274 proposed PythonInfo(spec=CPython3.10.8.final.0-64, exe=C:/msys64/mingw64/bin/python.exe, platform=win32, version='3.10.8 (main, Oct 15 2022, 19:00:40)  [GCC 12.2.0 64 bit (AMD64)]', encoding_fs_io=utf-8-utf-8) [INFO builtin:63]
274 accepted PythonInfo(spec=CPython3.10.8.final.0-64, exe=C:/msys64/mingw64/bin/python.exe, platform=win32, version='3.10.8 (main, Oct 15 2022, 19:00:40)  [GCC 12.2.0 64 bit (AMD64)]', encoding_fs_io=utf-8-utf-8) [DEBUG builtin:65]
276 symlink on filesystem does not work [DEBUG info:43]
277 filesystem is not case-sensitive [DEBUG info:24]
315 create virtual environment via CPython3Windows(dest=C:/msys64/home/yefan/ustc-ivclab.github.io/vvv, clear=True, no_vcs_ignore=False, global=False) [INFO session:48]
316 create folder C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/bin [DEBUG _sync:9]
317 create folder C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/lib/python3.10/site-packages [DEBUG _sync:9]
317 write C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/pyvenv.cfg [DEBUG pyenv_cfg:30]
317     home = C:/msys64/mingw64 [DEBUG pyenv_cfg:34]
318     implementation = CPython [DEBUG pyenv_cfg:34]
318     version_info = 3.10.8.final.0 [DEBUG pyenv_cfg:34]
318     virtualenv = 20.16.6 [DEBUG pyenv_cfg:34]
318     include-system-site-packages = false [DEBUG pyenv_cfg:34]
318     base-prefix = C:/msys64/mingw64 [DEBUG pyenv_cfg:34]
318     base-exec-prefix = C:/msys64/mingw64 [DEBUG pyenv_cfg:34]
319     base-executable = C:/msys64/mingw64/bin/python.exe [DEBUG pyenv_cfg:34]
320 copy C:/msys64/mingw64/lib/python3.10/venv/scripts/nt/python.exe to C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/bin/python.exe [DEBUG _sync:36]
323 copy C:/msys64/mingw64/lib/python3.10/venv/scripts/nt/pythonw.exe to C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/bin/pythonw.exe [DEBUG _sync:36]
327 create virtualenv import hook file C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/lib/python3.10/site-packages/_virtualenv.pth [DEBUG api:89]
328 create C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/lib/python3.10/site-packages/_virtualenv.py [DEBUG api:92]
329 ============================== target debug ============================== [DEBUG session:50]
330 debug via C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/bin/python.exe C:/msys64/mingw64/lib/python3.10/site-packages/virtualenv/create/debug.py [DEBUG creator:197]
329 {
  "sys": {
    "executable": "C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/bin/python.exe",
    "_base_executable": "C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/bin/python.exe",
    "prefix": "C:/msys64/home/yefan/ustc-ivclab.github.io/vvv",
    "base_prefix": "C:/msys64/mingw64",
    "real_prefix": null,
    "exec_prefix": "C:/msys64/home/yefan/ustc-ivclab.github.io/vvv",
    "base_exec_prefix": "C:/msys64/mingw64",
    "path": [
      "C:/msys64/mingw64/lib/python310.zip",
      "C:/msys64/mingw64/lib/python3.10",
      "C:/msys64/mingw64/lib/python3.10/lib-dynload",
      "C:/msys64/home/yefan/ustc-ivclab.github.io",
      "C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/lib/python3.10/site-packages"
    ],
    "meta_path": [
      "<class '_virtualenv._Finder'>",
      "<class '_frozen_importlib.BuiltinImporter'>",
      "<class '_frozen_importlib.FrozenImporter'>",
      "<class '_frozen_importlib_external.PathFinder'>"
    ],
    "fs_encoding": "utf-8",
    "io_encoding": "gbk"
  },
  "version": "3.10.8 (main, Oct 15 2022, 19:00:40)  [GCC 12.2.0 64 bit (AMD64)]",
  "makefile_filename": "C:/msys64/mingw64/lib/python3.10/config-3.10/Makefile",
  "os": "<module 'os' from 'C:/msys64/mingw64/lib/python3.10/os.py'>",
  "site": "<module 'site' from 'C:/msys64/mingw64/lib/python3.10/site.py'>",
  "datetime": "<module 'datetime' from 'C:/msys64/mingw64/lib/python3.10/datetime.py'>",
  "math": "<module 'math' from 'C:/msys64/mingw64/lib/python3.10/lib-dynload/math.cp310-mingw_x86_64.pyd'>",
  "json": "<module 'json' from 'C:/msys64/mingw64/lib/python3.10/json/__init__.py'>"
} [DEBUG session:51]
393 add activators for Bash, Batch, Fish, Nushell, PowerShell, Python [INFO session:61]
398 write C:/msys64/home/yefan/ustc-ivclab.github.io/vvv/pyvenv.cfg [DEBUG pyenv_cfg:30]
398     home = C:/msys64/mingw64 [DEBUG pyenv_cfg:34]
398     implementation = CPython [DEBUG pyenv_cfg:34]
398     version_info = 3.10.8.final.0 [DEBUG pyenv_cfg:34]
398     virtualenv = 20.16.6 [DEBUG pyenv_cfg:34]
398     include-system-site-packages = false [DEBUG pyenv_cfg:34]
399     base-prefix = C:/msys64/mingw64 [DEBUG pyenv_cfg:34]
399     base-exec-prefix = C:/msys64/mingw64 [DEBUG pyenv_cfg:34]
399     base-executable = C:/msys64/mingw64/bin/python.exe [DEBUG pyenv_cfg:34]
399 created virtual environment CPython3.10.8.final.0-64 in 345ms
  creator CPython3Windows(dest=C:/msys64/home/yefan/ustc-ivclab.github.io/vvv, clear=True, no_vcs_ignore=False, global=False)
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator [WARNING __main__:17]

yefan@DESKTOP-9OV63AO MINGW64 ~/ustc-ivclab.github.io
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit

yefan@DESKTOP-9OV63AO MINGW64 ~/ustc-ivclab.github.io
$ git commit
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[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

more info:

virtualenv python version did not match created version:
- actual version: <<error retrieving version from C:/Users/23203/.cache/pre-commit/repomcztfr3u/py_env-python3.10/Scripts/python.exe>>
- expected version: 3.10.8.final.0

Check the log at C:/Users/23203/.cache/pre-commit/pre-commit.log

@asottile
Copy link
Member

please open a new issue, the existing issues are for macos and debian

though I suspect there might be some output you're not showing since pre-commit produces a warning about mismatched cygwin and windows python's (which I believe is what you're hitting)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants