question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Only rely on Cache key for hit/misses regardless of Path

See original GitHub issue

Background

It appears that even though the Cache key being used to store and retrieve the cache is the same, a cache hit never occurs because the path string is different.

Here’s a screenshot of two jobs on main in a row with the same cache key…we get a cache miss but successful cache upload in both jobs: Screen Shot 2022-06-07 at 9 15 11 PM Screen Shot 2022-06-07 at 9 15 07 PM

The only thing different here is the path. This leads me to believe that the string to the path is influencing the caching which caught me by surprise and isn’t mentioned anywhere in the docs.

I saw this being mentioned in a couple other issues: https://github.com/actions/cache/issues/735#issuecomment-1036402013 https://github.com/actions/cache/issues/638#issuecomment-1002972310

This is a bummer because we currently isolate all builds by commit SHA so our path will always be different even though our key based on hashing yarn.lock doesn’t change which makes this module unusable in our current workflow, ie: path: ${{ github.sha }}/**/node_modules will always return a cache miss for any new commit even on the same branch.

Proposal

  • Make it clear in the docs that path influences how cache hits/misses
  • Allow option to strictly look at the Cache key ONLY for hits/misses, otherwise this is unusable for anyone using dynamic paths for their cache workflows

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

3reactions
dopplershiftcommented, Jun 12, 2022

It would be REALLY helpful to have the action print out when it fails due to the path. Right now it says:

Cache not found for input keys: proj-Linux-8.1.1-0

and I just spent a day trying to figure out how that happens but I was also seeing:

Unable to reserve cache with key proj-Linux-8.1.1-0, another job may be creating this cache. More details: Cache already exists. Scope: refs/pull/2529/merge, Key: proj-Linux-8.1.1-0, Version: 37db103cc447fb2a9f90faf2fc822b81d14099bd26899a64836c9e097ec1952c

when it turns out that (somehow) the cache was saved with a path of ~ instead of ~/local. Trying to debug that without a UI to look at cache details (or even an API to list the active caches) was terrible. (Not to mention trying to delete the bad one now is going to be fun…)

1reaction
pallavxcommented, Nov 23, 2022

Hi @BaseInfinity, we have recently updated our docs to indicate that the caching depends on cache-version, which in turn is based on path.

Hope this makes it clear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relative file path specified in cache key should get resolved ...
The Cache task key input expects a newline-delimited list of file names or strings. For file paths the hash of the file is...
Read more >
actions - Bountysource
See the "Cache Gradle dependency cache" step for each job, where it says: Cache not found for input keys: Windows-gradle-... But then in...
Read more >
Caching Dependencies - CircleCI
This document is a guide to caching dependencies in CircleCI pipelines. ... neither save_cache nor restore_cache support globbing for the paths key.
Read more >
CI build: How to cache different paths by different keys? - GitLab
Hello,. I've just solved this problem for myself by writing my own CI caching script that uses Google Cloud Storage (in the same...
Read more >
PHP require works only once after clearing APC Cache, then ...
If you have apc.stat=0 in your config, your problem could be related to this bug: https://bugs.php.net/bug.php?id=61854. Setting apc.stat=1 in my PHP config ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found