actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.36k stars 1.16k forks source link

cache restore on versions 3 and 4 not working #1361

Open mark-jordanovic-lewis opened 3 months ago

mark-jordanovic-lewis commented 3 months ago

The functionality of the cache action seems to be completely broken.

Configurations attempted:

The cache is being accessed on the same branch, in the same workflow (and later, if the first set of jobs pass).

Screenshot 2024-03-19 at 17 07 18 Screenshot 2024-03-19 at 17 17 01

Screenshot 2024-03-19 at 17 20 47

These screenshots pertain to the run of base cache action @v3, they are consistent across all configurations.

Cache version 2 works as expected.

Would definitely prefer to use the most recent versions.

mark-jordanovic-lewis commented 3 months ago

~Cause of the above issue is a difference in the actions/checkout version. There must be a difference in the way they reference the branch.~

matthiasPOE commented 3 months ago

Im currently getting:

Failed to save: Unable to reserve cache with key db09ccc890352b660ddd94bbcf7ce4b880b254099c5050c6059b00b0b4c5777e, another job may be creating this cache. More details: Cache already exists.

Not sure if its related but even deleting all caches it wont recreate them...

serpro69 commented 3 months ago

Same issue here. Have been wracking my brain why this doesn't work and then wanted to eventually open an issue and found out there's one already. Trying v2 now as recommended above.

upd: v2 works as expected

yrtimiD commented 2 months ago

@mark-jordanovic-lewis just to ensure, do you have exactly same value in the "path" parameter both in save and restore? I had different and restore failed too.

mark-jordanovic-lewis commented 2 months ago

Correct. Same parameters in each use of the action.

SimonSchick commented 2 months ago

We are seeing similar issues on v4 where the cache is not found despite clearly existing, only 1/5 runs are picked up correctly, is the cache action not reliable-ish?

njzjz commented 1 month ago

I encountered the same issue. Save v4 + restore v2 cannot work as well. Using save v2 + restore v2 can resolve the problem. However, it seems that Node.js 16 is going to be deprecated.

njzjz commented 1 month ago

I encountered the same issue. Save v4 + restore v2 cannot work as well. Using save v2 + restore v2 can resolve the problem. However, it seems that Node.js 16 is going to be deprecated.

I just found the reason: in v4, the path for restore and save must be the same. The error message doesn't give such information.

wmertens commented 1 month ago

@njzjz I'm encountering this problem too and the paths are the same for me

lsdm83114 commented 1 month ago

1

El dom, 26 de may. de 2024 19:55, Wout Mertens @.***> escribió:

@njzjz https://github.com/njzjz I'm encountering this problem too and the paths are the same for me

— Reply to this email directly, view it on GitHub https://github.com/actions/cache/issues/1361#issuecomment-2132119284, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGG5ZMWZ5SQ7TVB3OGEP663ZEGINXAVCNFSM6AAAAABE574CB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZSGEYTSMRYGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

MostefaKamalLala commented 4 weeks ago

Facing the same issue, any fix anytime soon?

I encountered the same issue. Save v4 + restore v2 cannot work as well. Using save v2 + restore v2 can resolve the problem. However, it seems that Node.js 16 is going to be deprecated.

restore v2 does not exist. it's only cache v2

hammzj commented 3 weeks ago

I can also confirm that v2 works, but v4 is completely broken. I am running a job with a matrix and am consistently getting failures because it cannot save nor restore the cache correctly.

serpro69 commented 3 weeks ago

To be frank I'm surprised how a core action like "cache" is still broken and no (visible) steps are taken to fix it... At times github actions seem completely unreliable for anything beyond small open-source stuff that isn't mission-critical.

markfickett commented 2 weeks ago

I hit this too. I was using actions/cache@v4.0.2 to save a virtual env and some other things, specifying a literal path on that job, and then setting job outputs for the different things in the path (like outputs: venv-path: my-venv). Then in another job, I used actions/cache/restore@v4.0.2 and referenced the same list of paths but via output variables (like paths: ${{ needs.setup-env.outputs.venv-path }}). As others have described, I could see the cache being created (and the setup-env job could pick up its own cache), but the downstream jobs say they can't find the cache. Changing both lists to be literal instead fixed the issue.

Variations of this issue seem to be reported in a number of other issues:

wmertens commented 2 weeks ago

@markfickett my paths are static and I'm experiencing this issue.

The problem is that it's intermittent.

danielkorte commented 5 days ago

Also confirming v4 is broken. I’m using static paths as well. I downgraded to v2 and everything works now.

matthiasPOE commented 5 days ago

@bethanyj28 @robherley @kotewar sorry about the pings but I cant believe this has been sitting here broken for so long