setup-node: cache-dependency-path with npm to a subfolder does not work

Description: cache-dependency-path to a subfolder results in Error: Some specified paths were not resolved, unable to cache dependencies.

Action version:

actions/setup-node@v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

The node 16.x version with corresponding npm version you get in Github.

node-version: 16 check-latest: true

Repro steps:

Repo structure:

<git root>
├── docs
│   └── README.md
├── firebase.json
└── functions
    ├── jest.config.ts
    ├── lib
    ├── node_modules
    ├── package.json
    ├── package-lock.json
    ├── src
    ├── tsconfig.json
    └── tsconfig.prod.json

Relevant workflow part:

jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      - name: setup node
        uses: actions/setup-node@v3
        with:
          node-version: 16
          check-latest: true
          cache: "npm"
          cache-dependency-path: "${ GITHUB_WORKSPACE }/functions/package-lock.json"

But for cache-dependency-path I’ve also tried these strings:

  • “functions/package-lock.json”
  • “./functions/package-lock.json”
  • “*/package-lock.json”

And they all fail:

Environment details
/opt/hostedtoolcache/node/16.18.0/x64/bin/npm config get cache
/home/runner/.npm
Error: Some specified paths were not resolved, unable to cache dependencies.

Expected behavior:

Caching to work even though the package lock file is in a subfolder called functions.

Actual behavior:

See repro steps above.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (7 by maintainers)

Most upvoted comments

⚠️ make sure you have checkout step in place (before setting up node step).

I would like to add a comment. I was facing this isse earlier today, and after digging for three hours, a teammate noticed that we missed the checkout step.

just to mention, I also had this issue a few hours ago, and the reason was that I had deleted package-lock.json in the PR. the deletion was done by mistake, once I put the file back it worked as usual.

⚠️ Make sure the package-lock.json is actually commited to the repository.

In my case, someone previously added the file name to the .gitignore, which we normally don’t do, so I just assumed it would be there.

Maybe this helps some more folks troubleshoot if google leads them here.

Hello @kentlarsson, to investigate and solve the problem we need to reproduce it. Currently i am not able to get the actual error despite i reproduced the repo according the description.

Can you please try to replace

  cache-dependency-path: "${ GITHUB_WORKSPACE }/functions/package-lock.json"

with

 cache-dependency-path: functions/package-lock.json

or

  cache-dependency-path: ${{github.workspace}}/functions/package-lock.json

as a quick fix that may help?

Hello @kentlarsson, thanks for you input. We start to investigate the issue.