pnpm: pnpm doesn't recognise cached/installed version of node and keeps downloading it
This is costing us hours of wasted time per week, so I’m raising it in the company discussion thread too.
pnpm version:
8.6.2
Code to reproduce the issue:
seems to happen on github actions exclusively. simply running:
pnpm i
We cache the node version downloaded by running the following:
- uses: actions/cache@v3
name: cache node
with:
path: /home/runner/.local/share/pnpm
key: ${{ runner.os }}-pnpm-node-cache
restore-keys: |
${{ runner.os }}-pnpm-node-cache-
We used to use a pnpm command (I forget which) to determine the cache dir name, but this in itself caused pnpm to download node (!!!) and thus it would stick even before the caching happened. So now we hardcode it, based on looking at where pnpm installs node to.
Expected behavior:
PNPM sees that node is installed on the machine, and doesn’t re-download it.
Actual behavior:
PNPM insists on downloading node from nodejs.org which frequently returns gateway errors or times out
Additional information:
node -v
prints: v19.9.0- Windows, macOS, or Linux?:
- Ubuntu Linux
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19 (10 by maintainers)
HI @KSXGitHub - I think you’re right.
I changed my caching from using an absolute path to a homedir prefixed path and I no longer see the
Fetching...
line. Oddly, I did do this in the course of trying to raise this issue, and the issue was not resolved, so I’m not entirely sure why this now works.Either way, it appears somehow that I’m now managing to cache the node install, and pnpm is behaving as I expect.
Thank you so much for your effort in helping me diagnose this.
Sorry for not being clear, I meant in GitHub CI. And it’s
~/setup-pnpm
(no dot).The relevant code: https://github.com/pnpm/action-setup/blob/d882d12c64e032187b2edb46d3a0d003b7a43598/src/install-pnpm/run.ts#L29-L31
BTW, in the github action, your
restore-keys
doesn’t match thekey
. You should remove it.