Skip to content

An error has occurred: InvalidManifestError #1133

Closed

Description

@kobeTianSilk

when i use pre-commit run --all-files
i got this error

[INFO] Initializing environment for git@github.com:kobeTianSilk/py3-bundleb2b.git.
An error has occurred: InvalidManifestError: 
=====> /Users/kobetian/.cache/pre-commit/repogfm2l6s7/.pre-commit-hooks.yaml does not exist
Check the log at /Users/kobetian/.cache/pre-commit/pre-commit.log

here is my code

default_language_version:
    python: python3.7
default_stages: [commit, push]
repos:
-   repo: git@github.com:kobeTianSilk/py3-bundleb2b.git
    rev: 896b92dcdbf567c5c0197fc6575e0c8bf6d2b5b3
    hooks:
    -   id: python-pylint
    -   id: python-isort
    -   id: autopep8
    -   id: black
        language_version: python3.7

Activity

  1. asottile commented on Sep 9, 2019

    @asottile
    Member

    as the error says, you're missing a .pre-commit-hooks.yaml in your repo

  2. kobeTianSilk commented on Sep 9, 2019

    @kobeTianSilk
    Author

    what should i do? please help me fix it.
    I did those operations

    • pre-commit install

    • pre-commit run --all-files
      when i got this error

    • pre-commit clean

    • pre-commit uninstall

    • pre-commit install

    • pre-commit run --all-files
      i don't fix this

  3. asottile commented on Sep 9, 2019

    @asottile
    Member

    your configuration is just wrong -- have you tried going through the quick start?

  4. kobeTianSilk commented on Sep 9, 2019

    @kobeTianSilk
    Author

    yes, i tried going through the quick start.
    but the /Users/kobetian/.cache/pre-commit/repogfm2l6s7/.pre-commit-hooks.yaml never change
    so that i got same error
    how do i fix it.
    In fact, I deleted the file and pulled the branch code back.

  5. asottile commented on Sep 9, 2019

    @asottile
    Member

    if you went through the quick start you should ahve a configuration (.pre-commit-config.yaml) that looks like:

    repos:
    -   repo: https://github.com/pre-commit/pre-commit-hooks
        rev: v2.3.0
        hooks:
        -   id: check-yaml
        -   id: end-of-file-fixer
        -   id: trailing-whitespace
    -   repo: https://github.com/psf/black
        rev: 19.3b0
        hooks:
        -   id: black

    Does that work?

  6. kobeTianSilk commented on Sep 9, 2019

    @kobeTianSilk
    Author

    yes it work, but i change my configuration, its not work any more.
    i don't know, where is my configuration error.

    and here is my code
    `
    default_language_version:
    python: python3.7
    default_stages: [commit, push]
    repos:

  7. asottile commented on Sep 9, 2019

    @asottile
    Member

    So see the repo value? that needs to point at a repository that has a .pre-commit-hooks.yaml file as described in Creating new hooks

    Also note to make code blocks on github you use triple-ticks:

        ```
        fixed width multi line
        code block here
        ```
  8. jczaplew commented on Apr 15, 2020

    @jczaplew

    I was running into this issue, and rm -rf ~/.cache/pre-commit followed by a pre-commit install fixed it

  9. asottile commented on Apr 15, 2020

    @asottile
    Member

    that shouldn't fix it, unless somehow the cache got corrupted -- if it happens again I'd be interested in the steps that led you there!

  10. jgosmann commented on Dec 26, 2020

    @jgosmann

    I was running into this issue, and rm -rf ~/.cache/pre-commit followed by a pre-commit install fixed it

    I had the same issue and could resolve it in the same way. I think it was caused because the path to my home directory changed and pre-commit was still referring to the old path for some reason:

    An error has occurred: InvalidManifestError:
    =====> /Volumes/Home/blubb/.cache/pre-commit/reportiehxn8/.pre-commit-hooks.yaml does not exist
    Check the log at /Users/jgosmann/.cache/pre-commit/pre-commit.log
    

    /Volumes/Home/blubb is the old path, /Users/jgosmann the new one.

  11. bagerard commented on Oct 27, 2021

    @bagerard
    Contributor

    I just faced this as well in a CI (gitlab runner), using pre-commit 2.15.0

    ...
    $ pre-commit run -a
    An error has occurred: InvalidManifestError: 
    =====> /builds/Wtn5_mwz/0/rbx-wp/tools/backend-repo-convention-checker/.cache/pre-commit/repo7ibyedry/.pre-commit-hooks.yaml is not a file
    Check the log at /builds/PTsjk8n3/0/rbx-wp/tools/backend-repo-convention-checker/.cache/pre-commit/pre-commit.log
    

    Adding a pre-commit clean command unlocked the situation

  12. asottile commented on Oct 27, 2021

    @asottile
    Member

    @bagerard that looks like the cache got moved which isn't a valid operation

  13. bagerard commented on Oct 27, 2021

    @bagerard
    Contributor

    Interesting, thanks for the feedback. I m using the gitlab pipeline 'cache' feature to "share" the pre-commit cache directory among the jobs of 1 project so the CI is indeed compressing and decompressing the cache directory in a per-job location. Isn't this standard practice in CI's?
    We ve been using pre-commit for a while now and didn't touch the cache config recently, it s the first time that we are facing this.

  14. asottile commented on Oct 27, 2021

    @asottile
    Member

    usually caches are extracted to a constant location -- it looks like in gitlab's situation that's not the case

  15. bagerard commented on Oct 27, 2021

    @bagerard
    Contributor

    Ok, if it reappears I ll investigate deeper, thanks again for the quick feedback 👍

  16. max-sixty commented on Dec 2, 2021

    @max-sixty

    This does seem to be an issue with GitLab's caching — the paths aren't consistent, and I'm guessing pre-commit using absolute paths.

    If anyone finds a solution to this, please let me know!

  17. bagerard commented on Dec 2, 2021

    @bagerard
    Contributor

    @max-sixty In our case, the issue appeared when we switch to k8s runners for our jobs. The jobs started to be more distributed, causing this issue to surface.

    Here's was what I discovered with the gitlab cache:

    • $CI_PROJECT_DIR is not constant, even in the docker runner, it's like /builds/g6YzdBjz/0/rbx-wp/lib/some_project/ , it has the runner ID.

    • cache path are always relative to $CI_PROJECT_DIR (by design in gitlab), in other words you can't map for instance /tmp/.cache to gitlab's cache, because this gets map to $CI_PROJECT_DIR/tmp/.cache silently

    I believe you can configure the runner to clone to a constant location (check builds_dir in https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runners-section) but we havn't tried that yet so I can't confirm that it works.

    Our workaround in the meantime was to move the pre-commit's cache directory back and forth between /tmp/.cache and $CI_PROJECT_DIR/.cache 🙂 , so that pre-commit can use it from a constant location AND gitlab can store back the cache 🧠

  18. bagerard commented on Dec 2, 2021

    @bagerard
    Contributor

    @asottile What do you think of documenting this in the doc section of pre-commit that describes how to set up gitlab's cache (https://pre-commit.com/#gitlab-ci-example). It could be as simple as "Be aware of this [#issue] related with non-constant build location in the runners" linking that with a new Issue that we would create in this repo. Happy to help if you think that is a good idea.

  19. asottile commented on Dec 2, 2021

    @asottile
    Member
  20. max-sixty commented on Dec 3, 2021

    @max-sixty

    Thanks @bagerard .

    In the end I defaulted to using the docker image for the pre-commit cache — not ideal for image sizes, but saves enough time to make it worthwhile, and we can rely on a single approach for caching.

  21. bsecker commented on Jan 21, 2022

    @bsecker

    @max-sixty I'm running into the same issue as you. Can you please share an example of your docker image-based fix?

  22. max-sixty commented on Jan 21, 2022

    @max-sixty

    The docker caching just involves running install-hooks in the dockerfile:

    
    # Requires a git repo, even an empty one
    RUN git init .
    RUN pip install pre-commit \
        && pip cache purge
    COPY .pre-commit-config.yaml .
    RUN pre-commit install-hooks
    
  23. unode commented on Jan 24, 2022

    @unode

    I'm also running into this problem although configured as documented.

    Could someone clarify what is it about the caching mechanism that makes it invalid after some time?
    Also, couldn't pre-commit simply regenerate the missing files if the cache is incomplete/invalid?

  24. asottile commented on Jan 24, 2022

    @asottile
    Member

    this issue has gotten super off topic -- the original question was about OP developing a hook and missing a file. general advice for open source unless you have exactly the same issue you should open a new one -- I'm going to lock this since it's off topic

    it has now devolved into gitlab having erratic cache locations

    yes it would be possible that pre-commit could regenerate in this case, however the steps to do so would be error prone, slow, and erratic and would be working around an external misuse. the cache must not move because it contains things which are not relocatable (executables, virtualenvs, etc.) and so building support for moving a cache just isn't feasible

  25. locked as off topic and limited conversation to collaborators on Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions