You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
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.
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
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.
@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
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 🧠
@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.
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.
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
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?
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
Activity
asottile commentedon Sep 9, 2019
as the error says, you're missing a
.pre-commit-hooks.yamlin your repokobeTianSilk commentedon Sep 9, 2019
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
asottile commentedon Sep 9, 2019
your configuration is just wrong -- have you tried going through the quick start?
kobeTianSilk commentedon Sep 9, 2019
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.
asottile commentedon Sep 9, 2019
if you went through the quick start you should ahve a configuration (
.pre-commit-config.yaml) that looks like:Does that work?
kobeTianSilk commentedon Sep 9, 2019
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:
rev: 896b92dcdbf567c5c0197fc6575e0c8bf6d2b5b3
hooks:
language_version: python3.7
`
asottile commentedon Sep 9, 2019
So see the
repovalue? that needs to point at a repository that has a.pre-commit-hooks.yamlfile as described in Creating new hooksAlso note to make code blocks on github you use triple-ticks:
jczaplew commentedon Apr 15, 2020
I was running into this issue, and
rm -rf ~/.cache/pre-commitfollowed by apre-commit installfixed itasottile commentedon Apr 15, 2020
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!
jgosmann commentedon Dec 26, 2020
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:
/Volumes/Home/blubb is the old path, /Users/jgosmann the new one.
bagerard commentedon Oct 27, 2021
I just faced this as well in a CI (gitlab runner), using pre-commit 2.15.0
Adding a
pre-commit cleancommand unlocked the situationasottile commentedon Oct 27, 2021
@bagerard that looks like the cache got moved which isn't a valid operation
bagerard commentedon Oct 27, 2021
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.
asottile commentedon Oct 27, 2021
usually caches are extracted to a constant location -- it looks like in gitlab's situation that's not the case
bagerard commentedon Oct 27, 2021
Ok, if it reappears I ll investigate deeper, thanks again for the quick feedback 👍
max-sixty commentedon Dec 2, 2021
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!
bagerard commentedon Dec 2, 2021
@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_dirin 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/.cacheand$CI_PROJECT_DIR/.cache🙂 , so that pre-commit can use it from a constant location AND gitlab can store back the cache 🧠bagerard commentedon Dec 2, 2021
@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.
asottile commentedon Dec 2, 2021
max-sixty commentedon Dec 3, 2021
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.
bsecker commentedon Jan 21, 2022
@max-sixty I'm running into the same issue as you. Can you please share an example of your docker image-based fix?
max-sixty commentedon Jan 21, 2022
The docker caching just involves running
install-hooksin the dockerfile:unode commentedon Jan 24, 2022
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?
asottile commentedon Jan 24, 2022
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