setup-node icon indicating copy to clipboard operation
setup-node copied to clipboard

Yarn cache not found

Open mdgeorge4153 opened this issue 4 years ago • 9 comments

Description: I get repeated misses for the yarn cache: ```Run actions/setup-node@v2 with: node-version: 16.x check-latest: true cache: yarn always-auth: false token: *** Attempt to resolve the latest version from manifest... Resolved as '16.14.0' Found in cache @ /opt/hostedtoolcache/node/16.14.0/x64 /usr/local/bin/yarn --version 1.22.17 /usr/local/bin/yarn cache dir /home/runner/.cache/yarn/v6

yarn cache is not found```

Action version: v2

Platform:

  • [X] Ubuntu
  • [ ] macOS
  • [ ] Windows

Runner type:

  • [X] Hosted
  • [ ] Self-hosted

Tools version: node-version: 16.x

Repro steps:
Public repo: https://github.com/Certora/rocket-joe-1/commit/ab70fe2af9afd51447945e0a3fcf6ad7745eff98

Expected behavior: Cache hit

Actual behavior: Cache miss after repeated reruns

mdgeorge4153 avatar Mar 11 '22 19:03 mdgeorge4153

This seems to be similar to bug #410 , but I have a public repo.

mdgeorge4153 avatar Mar 11 '22 19:03 mdgeorge4153

This also suddenly resolved for me. I think what may have been happening is that the cache gets updated later in the job, and if another job fails it fails fast and doesn't get around to doing the cleanup. I notice that the same issue was happening with setup-python and the pip cache, and resolved itself at the same time.

mdgeorge4153 avatar Mar 11 '22 19:03 mdgeorge4153

Actually it has reoccurred; I guess it is nondeterministic

mdgeorge4153 avatar Mar 11 '22 19:03 mdgeorge4153

Hello @mdgeorge4153. Thank you for your report. Does the error still reproduce?

dmitry-shibanov avatar Mar 28 '22 08:03 dmitry-shibanov

Hello @mdgeorge4153 Just a gentle reminder. Could you confirm that you can still reproduce this issue?

marko-zivic-93 avatar Apr 01 '22 08:04 marko-zivic-93

I will close this issue. If you experience this issue again, please feel free to leave a comment here or to create a new issue.

marko-zivic-93 avatar Apr 04 '22 09:04 marko-zivic-93

Preface: I'm on [email protected] - can't upgrade to 3 because of snyk :/

I've been seeing this issue since enabling cache: 'yarn' Private repo unfortunately.

I've tried doing a couple small pushes with no package.json or yarn.lock changes to see if those changes were causing the cache not to be found but no luck so far.

just-Bri avatar Oct 07 '22 16:10 just-Bri

I had the same issue and found a way to solve this.

I checked the log in the later job Post Run actions/setup-node@v3 and found that there was a warning /bin/tar: unrecognized option: posix so the cache couldn't be built. It was because I was using alpine Linux image (more explanation here).

So changing to use normal Linux image solved this for me.

damhonglinh avatar Feb 09 '23 11:02 damhonglinh

Seems it caches only after job is succeeded

Знімок екрана 2024-05-03 о 18 13 26 With code below I managed to configure best caching despite workflow fails or not.
name: Check With Full Cache Workflow

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  run-linters:
    name: Run Linters
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version-file: .nvmrc

      - name: Get Yarn Cache Directory Path
        id: yarn-cache-dir-path
        run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

      - name: Restore Dependencies Cache
        uses: actions/cache/restore@v3
        id: restore-cache
        with:
          path: |
            node_modules
            ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
          restore-keys: ${{ runner.os }}-

      - name: Install Dependencies
        run: yarn

      - name: Cache Dependencies
        uses: actions/cache/save@v3
        if: steps.restore-cache.outputs.cache-hit != 'true'
        with:
          path: |
            node_modules
            ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}

      - name: Lint
        run: yarn lint

wildstyles avatar May 03 '24 15:05 wildstyles