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

pre-commit hook does not work on Windows #473

Closed
radoering opened this issue Aug 16, 2024 · 3 comments
Closed

pre-commit hook does not work on Windows #473

radoering opened this issue Aug 16, 2024 · 3 comments

Comments

@radoering
Copy link

When I try to use the pre-commit hook on Windows it always fails with

UnicodeEncodeError: 'charmap' codec can't encode character '\u2705' in position
1: character maps to <undefined>

or

UnicodeEncodeError: 'charmap' codec can't encode character '\u274c' in position
1: character maps to <undefined>

The unicode characters mentioned in the error are ✅ and ❌.

I tried it in cmd, Powershell and Git Bash and always got these errors.

I can reproduce this issue by just creating an empty git repo with just a .pre-commit-config.yaml with:

repos:
  - repo: https://github.com/scientific-python/cookie
    rev: 2024.04.23
    hooks:
      - id: sp-repo-review

and running pre-commit run --all-files.

@henryiii
Copy link
Collaborator

As a quick fix, you can set PYTHONUTF8=1 and I think that will fix it (Python 3.15 would fix it too, but that's a couple of years away). Something is missing the encoding specifier, hopefully in repo-review or sp-repo-review. Will check.

@henryiii
Copy link
Collaborator

This has been fixed in https://github.com/scientific-python/repo-review/releases/tag/v0.11.1 - though pre-commit caches globally, so there will be a new release here soon which should ensure that gets picked up.

@henryiii
Copy link
Collaborator

Fixed in latest releases!

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

No branches or pull requests

2 participants