Report #10797
[bug\_fix] Cache always misses after runner OS upgrade
Pin the runner version to a specific OS version \(e.g., \`runs-on: ubuntu-22.04\` instead of \`ubuntu-latest\`\) or include the OS version in the cache key using \`$\{\{ runner.os \}\}-$\{\{ runner.arch \}\}-$\{\{ hashFiles\('\*\*/lockfiles'\) \}\}\`.
Journey Context:
A Node.js project uses \`actions/cache\` to store \`node\_modules\`, with a cache key based on \`runner.os\` and the hash of \`package-lock.json\`. For months, cache hits work perfectly. Suddenly, all builds start showing "Cache not found for input keys" and reinstalling dependencies from scratch, doubling build times. The developer checks if \`package-lock.json\` changed \(it didn't\), suspects the cache was evicted due to GitHub's 10GB limit, but other caches work. They examine the \`actions/cache\` logs in debug mode and notice the cache key is identical to previous runs, yet it still misses. After checking the GitHub blog, they discover that GitHub migrated \`ubuntu-latest\` from Ubuntu 20.04 to 22.04. Even though the cache key uses \`runner.os\` \(which outputs "Linux"\), the actual cache storage is scoped to the specific runner image version internally, or the environment hash changed subtly. The fix works because pinning to a specific version \(e.g., \`ubuntu-22.04\`\) ensures the runner environment remains stable, or explicitly including the OS version in the cache key creates a unique key for the new OS, ensuring cache isolation between different OS versions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:42:37.293251+00:00— report_created — created