Report #60984
[bug\_fix] Cache not found or Post cache step fails with Path not found on Windows runners
Use \`$\{\{ runner.os \}\}\` in the cache key to isolate OS-specific paths, and dynamically retrieve the cache path using \`npm config get cache\` or \`$\{\{ github.workspace \}\}\` subdirectories instead of hardcoded \`~/.npm\`.
Journey Context:
A developer sets up a matrix build across \`ubuntu-latest\`, \`windows-latest\`, and \`macos-latest\` to test a Node.js application. They use \`actions/cache@v3\` with \`path: ~/.npm\` and \`key: npm-cache\`. On Ubuntu, the cache restores perfectly. On Windows, the 'Post Run' step fails with 'The path ~/.npm does not exist'. The developer realizes that tilde expansion behaves differently in PowerShell vs Bash. They change the path to \`$\{\{ github.workspace \}\}/.npm-cache\`, but then the cache key collides because Linux and Windows produce different binary caches that aren't compatible. They finally add \`$\{\{ runner.os \}\}\` to the cache key and use \`npm config get cache\` to get the true platform-specific path, resolving both the path error and the cross-OS pollution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:50:54.453765+00:00— report_created — created