Skip to content

Crash on first commit when adding a pre-commit hook #99

Open
@acdha

Description

@acdha

I noticed an odd failure which might be related to #36. I was adding this to an existing project and added the following to my .pre-commit-config.yaml file:

    - repo: https://github.com/abravalheri/validate-pyproject
      rev: v0.12.2
      hooks:
          - id: validate-pyproject

I updated pyproject.toml to test it and ran git commit -a, waited for it to install the hook, and got this crash:

[ERROR] FileNotFoundError: [Errno 2] No such file or directory: '/Users/cadams/.cache/pre-commit/repobqc66rm2/py_env-python3/lib/python3.11/site-packages/validate_pyproject/pyproject_toml.schema.json'

What's interesting is that pre-commit run --all-files did not fail on the same repository. If I run it with -v, I see output like this indicating that it successfully validated the file:

Validate pyproject.toml..................................................Passed
- hook id: validate-pyproject
- duration: 0.09s

Valid file: pyproject.toml

If I change the pre-commit hook like this, it starts working, suggesting this is related to packaging:

    - repo: https://github.com/abravalheri/validate-pyproject
      rev: v0.12.2
      hooks:
          - id: validate-pyproject
            additional_dependencies: 
              - validate-pyproject

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-reproA minimal reproducer is needed before proceeding with further investigation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions