GitHub Actions Cache "Path Validation Error" / No Files Matched the Glob
actions/cache warns that no files matched the configured path, so the save is a no-op. The directory does not exist yet, the glob is wrong, or the path is relative to an unexpected base - every later restore then misses.
What this error means
The cache step logs that there are no matching files for the path, saves nothing, and subsequent runs always report a cache miss for that key even though the key is stable.
Warning: There is no matching files for the path '~/.cache/build'.
# nothing is cached, so restores always missCommon causes
Path does not exist at save time
If the directory is generated later (or never), the cache save finds nothing to store. The cache post-step runs at job end, but the path still must exist by then.
Wrong glob or base directory
A relative path is resolved from the workspace; a typo, a missing ~ expansion, or a non-recursive glob can match nothing on this runner.
How to fix it
Point path at a real, populated directory
Cache a path that exists by the end of the job, and verify it before relying on the cache.
- uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
key: deps-${{ hashFiles('package-lock.json') }}
- run: ls -la node_modules | head # confirm it was populatedFix the glob and base path
- Use an absolute path or ~ for home-relative caches so it does not depend on the working directory.
- Ensure the step that creates the directory runs before the cache save (i.e. before job end).
- Echo the resolved path and list it to confirm files exist before caching.
How to prevent it
- Cache only paths that exist by job end.
- Use absolute or ~-anchored paths to avoid base-directory surprises.
- Verify the cached directory is populated before trusting the cache.