GitHub Actions hashFiles returned empty (no files matched)
hashFiles returns an empty string when its glob matches no files. That empty value collapses your cache key, so every run shares (and overwrites) the same broad key, or the cache never restores meaningfully.
What this error means
A warning notes no files matched the hashFiles pattern, and the cache key ends with an empty hash segment.
github-actions
Warning: No file matched to [package-lock.json]. The glob pattern is correct?
key: deps-${{ runner.os }}-Common causes
Glob path is wrong or file not checked out
The lockfile lives in a subdirectory, or checkout has not run, so the glob matches nothing.
File genuinely absent for this project type
The hashed file does not exist in the repo, so the pattern can never match.
How to fix it
Point hashFiles at a real, checked-out file
- Ensure checkout runs before the cache step.
- Use a glob that matches the actual lockfile path, including subdirectories with **.
- Re-run and confirm the key has a non-empty hash.
.github/workflows/ci.yml
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: node_modules
key: deps-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}How to prevent it
- Verify the hashFiles glob matches a checked-out file before relying on it.
- Run checkout before any cache step that hashes repo files.
Related guides
GitHub Actions cache hit but restore left files missingFix the GitHub Actions issue where actions/cache reports a hit but the build still rebuilds because not all c…
GitHub Actions cache key changes every run (never hits)Fix a GitHub Actions cache that never hits because the key includes a value that changes on every run, such a…
GitHub Actions "Post job cleanup failed"Fix the GitHub Actions error where an action's post step (cache save, checkout cleanup) fails after the job's…