setup-node: Path Validation Error on Cleanup

Description: Getting Error: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved. on cleanup for action

Action version: 3.7.0

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version: Node 18, pnpm 7.12.1

Repro steps:
Example run

Expected behavior: Clean up with no errors.

Actual behavior: Path validation error on clean up.

This appears to be new to 3.7.0, because when we pinned the version to 3.6.0, it went away.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 10
  • Comments: 21 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I’m also running into the problem of

Error: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved

on Cleanup. Running on @main does not seem to do anything. Has there been any development on new ideas on this topic?

Please validate my account

The error is related to the caching layer, not setup-node itself.

As it’s a post-setup step, it should just show a warning instead of throwing an error, as this breaks actions that use multiple jobs.

This error can occur if there’s an apparently valid cache entry stored for the action and the repo suffered some change after the cache was made, like a folder rename.

Workaround

Running gh cache delete -a, or manually deleting node-cache- cache entries should fix the issue.

Also, editing package-lock.json, yarn.lock or pnpm-lock.yaml by just updating some package will create a new cache key and ignore the older one.

Important

Do not try to be clever and cache node_modules. It uses symlinks/hard links to save space, but caching it can make debugging your actions a living hell, whence setup-node just don’t cache it. Node will show weird errors that are hard to make sense, and the action can fail sometimes, but not always (depending on cache invalidation).

Simply configure cache and cache-dependency-path on setup-node and let it cache the global packages that it’ll just work.

I am running into this issue with node 18.17 + yarn 4 once a while. Any debugging I can do to help resolve this issue?

Fyi I had this error when using node v16 and when I changed to v18 it now works with pnpm cache!

Note the other thing I noticed is that it was failing in a workflow of mine that I actually did not run pnpm install with so potentially the issue was that there was no cache created and that is why I was getting this error 🤷‍♂️ … in case someone else runs into the same scenario.

Anyways, below is working for me now:

name: Test pnpm install and cache

on:
  workflow_dispatch:

jobs:
  test-pnpm-install-and-cache:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest, macos-latest]

    steps:
      - name: Checkout the code
        uses: actions/checkout@v3
      - name: Setup pnpm
        uses: pnpm/action-setup@v2
        with:
          version: 8
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: 'pnpm'
      - name: Install dependencies
        run: pnpm install --frozen-lockfile
      - name: Test pnpm list
        run: pnpm list
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Hope this helps someone!

Hello, @NicholasLYang ! Thank you for creating the issue, we will take a closer look into it and see what can be done 😃