Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache-dependency-path with npm to a subfolder does not work #624

Closed
2 of 5 tasks
kentlarsson opened this issue Nov 14, 2022 · 21 comments
Closed
2 of 5 tasks

cache-dependency-path with npm to a subfolder does not work #624

kentlarsson opened this issue Nov 14, 2022 · 21 comments
Assignees
Labels
bug Something isn't working

Comments

@kentlarsson
Copy link

kentlarsson commented Nov 14, 2022

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.

@kentlarsson kentlarsson added bug Something isn't working needs triage labels Nov 14, 2022
@dsame
Copy link
Contributor

dsame commented Nov 15, 2022

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

@kentlarsson
Copy link
Author

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

Thank you! Let me know if I can help out with any information. (I looked for some kind of verbose/debug flag for the action but didn't find one.)

@dsame dsame self-assigned this Nov 16, 2022
@dsame
Copy link
Contributor

dsame commented Nov 16, 2022

Hello @kentlarsson, i tried to reproduce the problem but the following pipeline works as expected
https://github.com/akv-demo/setup-node-test/actions/runs/3477559354/workflow

This the build run the npm files are cached
https://github.com/akv-demo/setup-node-test/actions/runs/3477511902/jobs/5813760043#step:7:29

And here the cache it used
https://github.com/akv-demo/setup-node-test/actions/runs/3477559354/jobs/5813863202#step:3:73

Can you please double check you have package-lock.json commited in or fork the branch i created i try to reproduce the problem with it?

@kentlarsson
Copy link
Author

Repo structure:

Hey! Thanks for investigating!

Yes it's committed, it's quite essential for us (but I know you have to ask of course).

I'll try to fork that repo and see if I can reproduce the issue. It might take a week though, but I'll do it and get back to you in this thread. Thanks again!

@dmitry-shibanov
Copy link
Contributor

Hello @kentlarsson. Do you have any updates ?

@kentlarsson
Copy link
Author

Sorry, I've had too much to do. But I just learned about ACTIONS_RUNNER_DEBUG which I guess you used? So I'll try to add that tomorrow to our repo and see what it says.

If I just fork your repo I guess we'd only make sure that the files are where they should. And since the ascii tree I had in my debug report was from the tree command I'd assume so (and package-lock we use all the time). I'll probably get more useful info the above way. Or did you have other reasons for suggesting a fork than to make sure package-lock.json and node_modules actually reside under functions/ ?

@dsame
Copy link
Contributor

dsame commented Nov 28, 2022

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?

@kentlarsson
Copy link
Author

Hey! Thanks for your attention! I'm sorry I answer a bit later then I say, it's been a very busy period at work. But I'll do my best to give the best info I can asap though. :-)

I tried both

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

And

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

But I got the same result. I also enabled ACTIONS_STEP_DEBUG but I still see no more info then Error: Some specified paths were not resolved, unable to cache dependencies.

I'll try the fork now so that I've tried everything suggest. Will be back with those results.

@kentlarsson
Copy link
Author

kentlarsson commented Nov 30, 2022

Also to quadruple check paths:

❯ git rev-parse --show-toplevel
/home/kent/xyz/backend/npm-cache-test

npm-cache-test on  npm-cache-test [$]
❯ pwd
/home/kent/xyz/backend/npm-cache-test

npm-cache-test on  npm-cache-test [$]
❯ ls -l functions/package*
.rw-r--r-- 1.8M kent 30 Nov 22:55 functions/package-lock.json
.rw-r--r-- 2.7k kent 30 Nov 22:31 functions/package.json

@kentlarsson
Copy link
Author

kentlarsson commented Nov 30, 2022

I forked your repo now!

At first I just forked main, it was my first fork plus I am a bit sloppy. Anyway, I copy pasted over your workflow file with npm and I could reproduce the error.

I ran the CI action four times, from oldest to newest:

  1. Green/Worked because it still had yarn in there.
  2. Commit when I changed to your npm workflow
  3. I ran it manually as well
  4. I enabled ACTIONS_RUNNER_DEBUG to see if I could get more debug info (but I didn't see any)

Maybe the container is somehow different from what you expect?

Thanks again for helping me out!

@edimossilva
Copy link

Hey @kentlarsson I believe that I am having kind of the same issue in this pipeline, this is my config file.

Maybe I am missing something, but please let me know if you spot anything relevant

@kentlarsson
Copy link
Author

@edimossilva Seems likely, you also use a subfolder. We'll see if we can give @dsame the info he needs to know what's going on and hopefully fix it. :-) I guess if you follow this thread we'll see it together.

@dsame
Copy link
Contributor

dsame commented Dec 13, 2022

@kentlarsson i see you workflow points out to cache-dependency-path: functions/package-lock.json but your source tree does not have the functions filder, but they have sub instead
https://github.com/kentlarsson/setup-node-test/tree/9f1d0f4edd042a93cfadcb620933c1e0a7b0e748

I checked all 3 failed builds and the all have the same issue with functions/sub inconsistency

@dsame
Copy link
Contributor

dsame commented Dec 13, 2022

@edimossilva
The source tree has no backend-rails/yarn.json referenced from workflow https://github.com/espoo-dev/group-habits/pull/74/files#diff-1536c0c85181fcefa4770c87757cc177b95bc82922fde14dc443bcf55c8cb94bR56.

I gusee this should be cache-dependency-path: backend-rails/yarn.lock'

@dsame
Copy link
Contributor

dsame commented Dec 20, 2022

@kentlarsson @edimossilva i am going to close this issue because of not activity for more than a week, but please feel free to reopen it or create new one in case if the issue exists.

@dsame dsame closed this as completed Dec 20, 2022
@pedrohaccorsi
Copy link

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.

@RMCampos
Copy link

⚠️ 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.

@zirkelc
Copy link

zirkelc commented Jul 20, 2023

⚠️ 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.

That solved it for me!

@ayoolaore
Copy link

Hi everyone, I have a similar issue with the same error as @kentlarsson. I believe my issues is due to the fact that each component in my root directory has its own package.lock buried two levels below the root working directory.

<git root>
├── docs
│   └── README.md
└── infrastructure
    ├── account
        ├── lib
        ├── node_modules
        ├── src
        ├── package.json
        ├── package-lock.yaml
        ├── tsconfig.json
        └── tsconfig.prod.json

@theister
Copy link

theister commented Dec 8, 2023

⚠️ 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.

@n0099
Copy link

n0099 commented Feb 12, 2024

It seems only ${{ github.workspace }} worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants