cache: hashFiles function throwing error.
We are facing issue with node caching today on ubuntu-18.04. Following is the error
hashFiles('../../**/package-lock.json') failed. Fail to hash files under directory
This has been working for the past 2 years. However starting today morning we are facing this issue
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-cache-${{ hashFiles('../../**/package-lock.json')}}
restore-keys: |
${{ runner.os }}-node-cache-
24 hours back it was running as expected
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 24 (6 by maintainers)
Commits related to this issue
- Fix silent hashFiles failure that is now failing https://github.com/actions/cache/issues/753 — committed to alphagov/e-petitions by pixeltrix 2 years ago
- Use absolute path for hashFiles https://github.com/actions/cache/issues/753 — committed to SeneddCymru/e-petitions by pixeltrix 2 years ago
- Use absolute path for hashFiles https://github.com/actions/cache/issues/753 — committed to ScottishParliament/e-petitions by pixeltrix 2 years ago
- Use absolute path for hashFiles https://github.com/actions/cache/issues/753 — committed to alphagov/e-petitions by pixeltrix 2 years ago
- [skip e2e]Use absolute path for hashFiles Related with issue https://github.com/actions/cache/issues/753 Signed-off-by: Jenny Li <jing.li@zilliz.com> — committed to jennyli-z/milvus by deleted user 2 years ago
- [skip e2e]Use absolute path for hashFiles (#15894) Related with issue https://github.com/actions/cache/issues/753 Signed-off-by: Jenny Li <jing.li@zilliz.com> — committed to milvus-io/milvus by deleted user 2 years ago
- Add performance points for Proxy Signed-off-by: cai.zhang <cai.zhang@zilliz.com> [skip e2e] Update committer/maintainer list (#15875) Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com> Modify t... — committed to xiaocai2333/milvus by xiaocai2333 2 years ago
- Add performance points for Proxy (#15869) Signed-off-by: cai.zhang <cai.zhang@zilliz.com> [skip e2e] Update committer/maintainer list (#15875) Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com> ... — committed to milvus-io/milvus by xiaocai2333 2 years ago
- [skip e2e]Use absolute path for hashFiles (#15894) Related with issue https://github.com/actions/cache/issues/753 Signed-off-by: Jenny Li <jing.li@zilliz.com> Signed-off-by: Congqi Xia <congqi.xia@z... — committed to congqixia/milvus by deleted user 2 years ago
- [skip e2e]Use absolute path for hashFiles (#15894) (#15935) Related with issue https://github.com/actions/cache/issues/753 Signed-off-by: Jenny Li <jing.li@zilliz.com> Signed-off-by: Congqi Xia <con... — committed to milvus-io/milvus by congqixia 2 years ago
- Document hashFiles() recent failures. See: https://github.com/actions/runner/issues/449 https://github.com/actions/cache/issues/753 https://github.com/actions/toolkit/pull/1015 — committed to kdeldycke/workflows by kdeldycke 2 years ago
We also started running into this issue today. After enabling step debug logging, it seems that for us the error was caused by a permissions issue. Specifically, during the CI run, a folder was created by Docker within the workspace with permissions that meant that
hashFiles
could not search that folder for files which matched our search pattern. I assume that this failed silently before, but is now an error due to https://github.com/actions/runner/pull/1678.We are able to resolve this either by making the pattern more concrete (e.g. instead of using
**/*.cabal
, we could use**/foo.cabal
, but then we need to be careful about adding all package files explicitly now and in the future) or by moving the folder created by Docker outside the workspace.In any case, I am wondering though if the solution implemented by https://github.com/actions/runner/pull/1678 could be improved. At least, it would be nice to have a better indication of what the error is without having to enable step debug logging. Perhaps the errors should be warnings instead? Or perhaps there should only be an error if
hashFiles
returns an empty string?I resolved this by changing this:
to this:
In my case I’m using
cypress-io/github-action
and was getting theEACCES: permission denied
error. I fixed it by running containers as user 1001According to this old version of the
cypress-io/github-action
README:@Chrischuck Yes, if the cause is due to [Permission denied], you do not need to do anything. 👌🏿
If you want to see the cause of the hashFiles error, you need to enable debug logging. If you see [Permission denied] (example), my PR will automatically fix it.
However, since it has not been reviewed, it remains to be seen when a fix will be made… 😩
In our case it was caused because there was an access error during file matching.
To debug the issue you can manually run hashFiles by logging in to the self-hosted worker and evaluating (in the work directory)
In my case, hashFiles fails because of a dangling symlink that throws an Error: ENOENT. If it succeeds you get the hash printed to stdout, e.g.:
And it clearly is reevaluated in the Post Run actions/cache@v2 step, because that is where it errors out for me. That makes zero sense at all; the cache key must be the one from the Run actions/cache@v2 step. Later there will typically be build artifacts that will be picked up by globs.
For me, specifying an absolute path in the key
just creates an empty key, i.e.
cache-key-
as if hashfiles returns the empty string. This is a self-hosted runner, in case it matters.I see lots of projects linked on this issue that “fixed” this and now have keys that do not have any hash in them any more, this is going to be a cluster**** when they start changing their sources and keep downloading stale caches.
Really
hashFiles
should error out if there is a glob that does not match anything, or if there is a file that does not exist. Ideally with a sane error message that tells us what the whole glob was, including any prepended workspace paths. Hashfiles should never return the empty string.Ours problem is
**/composer.lock
instead. I’m wondering if changing tocomposer.lock
would cause any problem, since it will then only hash thecomposer.lock
file in root folder, and not including those undervendors
folder. I reckon it’s okay because if any of the composer.lock files are changed undervendors
, then the maincomposer.lock
under root folder should have changed first (lib versions, etc), right?After discussing this internally, we think this is related to - https://github.com/actions/runner/pull/1678. Essentially
hashFiles
was previously failing silently but with the new runner version it will raise an Error instead.You can also see this was the case in @moerishabh 's screenshot, where it shows:
Essentially, the hash was never getting computed + added to the key.
@moerishabh I think you can fix that by removing the relative paths of
../../
. @Dragory I’m not exactly sure why yours is failing. Could you please enable step debug logging, re-run the workflow, and look at the extra debug output to see what error it shows?@moerishabh Any reason why you are still using the old v1 version of API instead of v2? Regarding your problem- Can you try giving an absolute path for package-lock.json and avoid using ** as it may cause problems for subnested package-lock.json files inside node_modules ? or is it what you want ?