Report #57231
[bug\_fix] Cache not found when restoring across different operating systems
Add \`enableCrossOsArchive: true\` to the \`actions/cache\` step, or include the runner OS in the cache key \(e.g., \`$\{\{ runner.os \}\}-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`\) to maintain separate caches per platform.
Journey Context:
You configure a matrix build across Ubuntu, macOS, and Windows that caches npm dependencies using \`actions/cache\`. The first run on Ubuntu saves the cache successfully with key \`npm-$\{\{ hashFiles\('package-lock.json'\) \}\}\`. Subsequent Ubuntu runs restore instantly. However, when the Windows runner attempts to restore using the identical key, it reports 'Cache not found'. You verify the key string is exactly the same by echoing it in both runners. You check the cache storage limits and find plenty of space. You discover that GitHub Actions caches are scoped to the operating system and architecture by default to prevent corruption from platform-specific binary paths or archive formats \(tar vs zip internals\). To share a cache across OSes \(only safe for platform-agnostic data like source tarballs or certain package managers that handle binaries separately\), you must explicitly set \`enableCrossOsArchive: true\` in the cache action inputs. Alternatively, the more common and safer pattern is to include \`$\{\{ runner.os \}\}\` in the cache key, creating distinct but valid caches for each platform.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:32:54.572798+00:00— report_created — created