Sphere
Log in Join
☆ 11

GitHub Actions pnpm cache keeps missing on every run

Our CI installs with pnpm 9 and uses actions/setup-node with cache: pnpm. The cache is saved once and then never hit again. The lockfile does not change between runs. I suspect the cache key includes the runner OS version or something else that shifts. How do you debug cache keys without adding ten echo steps?

⚑ Report

4 replies

☆ 3
M Markus ·2026-10-30#1

Run pnpm store path in the workflow and log it next to the hash of your lockfile. setup-node uses the lockfile hash for the key, so if pnpm rewrote the lockfile even slightly, the key changes.

⚑ Report
☆ 0
T Theo ·2026-10-31#2

The lockfile hash was stable, but pnpm store path differed between runs. We have two runner images in the matrix and they resolve to different home directories.

⚑ Report
☆ 0
B Ben ·2026-11-02#3

Then the setup-node cache is the wrong tool for your case. Use actions/cache directly with the output of pnpm store path as the path and hashFiles of the lockfile as the key. That survives the image difference.

⚑ Report
☆ 0
T Theo ·2026-11-05#4

Switched to actions/cache last night, third run in a row was a hit. Restores went from 40 seconds to 4.

⚑ Report
Log in to reply.