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

BUG - hooks not working on windows 10, when user account name contains non-ascii characters #1711

Closed
Najiva opened this issue Nov 23, 2020 · 7 comments · Fixed by #1713
Closed

Comments

@Najiva
Copy link

Najiva commented Nov 23, 2020

When user account name contains non-ascii characters such as 'š', such that python executable ends up for example in C:\Users\john.š\.cache\pre-commit\repo\py_env-python3.8\Scripts\python.exe, when committing to the git repository following message appears:

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

PS: fucntion os.path.isfile() in parse_shebang.normexe() returns False, even though the executable exists there and is a file.

@asottile
Copy link
Member

please share your configuration and version information as well as the log file

@Najiva
Copy link
Author

Najiva commented Nov 24, 2020

version information

pre-commit version: 2.9.0
sys.version:
    3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
sys.executable: c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\scripts\python.exe
os.name: nt
sys.platform: win32

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 "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\error_handler.py", line 65, in error_handler
    yield
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\main.py", line 347, in main
    return hook_impl(
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\commands\hook_impl.py", line 217, in hook_impl
    return retv | run(config, store, ns)
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\commands\run.py", line 401, in run
    install_hook_envs(hooks, store)
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\repository.py", line 213, in install_hook_envs
    _hook_install(hook)
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\repository.py", line 88, in _hook_install
    raise AssertionError(
AssertionError: BUG: expected environment for python to be healthy() immediately after install, please open an issue describing your environment

Yaml

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

@asottile
Copy link
Member

could you also share the output of pip freeze?

@Najiva
Copy link
Author

Najiva commented Nov 24, 2020

appdirs==1.4.4
asgiref==3.3.0
cfgv==3.2.0
distlib==0.3.1
dj-database-url==0.5.0
Django==3.1.3
filelock==3.0.12
identify==1.5.10
nodeenv==1.5.0
pre-commit==2.9.0
psycopg2==2.8.6
pytz==2020.4
PyYAML==5.3.1
six==1.15.0
sqlparse==0.4.1
toml==0.10.2
virtualenv==20.2.1

@asottile
Copy link
Member

hmmm I can't reproduce :(

could you set a breakpoint inside the healthy() method and show me a few things?

image

here's (for example) some debug information that would be helpful:

image

@Najiva
Copy link
Author

Najiva commented Nov 25, 2020

I think you cannot reproduce to issue, because you have python installed in C:\Python39. Try installing it into subdirectory of the C:\Users\john.š. I have tried to install python directly to C:\Python39 (like you did) and the error went away. (I believe you will have to convert encoding of the pre-commit file to UTF-8 too)

@asottile
Copy link
Member

Cool! There's a patch for this in #1713 -- I was able to reproduce after all

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

Successfully merging a pull request may close this issue.

2 participants