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

actions/cache@v2 error: Cache Service Url not found, unable to restore cache #285

Closed
grische opened this issue Jun 20, 2020 · 15 comments
Closed
Labels
area/runner Relating to errors in the runner kind/bug Something isn't working stale

Comments

@grische
Copy link

grische commented Jun 20, 2020

I am not sure how the cache is meant to work with nektos/act, but when working around bug #257, the cache will always throw a cache-hit=false with the following errors:

☁  git clone 'https://github.com/actions/cache' # ref=v2
🐳  docker cp src=/home/grische/.cache/act/actions-cache@v2 dst=/actions/
❓   ::save-state name=CACHE_KEY::Linux-2b7ee04efeb2a8c4ea27558750b1c2dee27f1692a30af56727638c98655a2410
πŸ’¬  ::debug::Resolved Keys:
πŸ’¬  ::debug::["Linux-2b7ee04efeb2a8c4ea27558750b1c2dee27f1692a30af56727638c98655a2410"]
πŸ’¬  ::debug::Checking zstd --version
πŸ’¬  ::debug::*** zstd command line interface 64-bits v1.3.3, by Yann Collet ***
πŸ’¬  ::debug::getCacheEntry - Attempt 1 of 2 failed with error: Cache Service Url not found, unable to restore cache.
πŸ’¬  ::debug::getCacheEntry - Attempt 2 of 2 failed with error: Cache Service Url not found, unable to restore cache.
| [warning]getCacheEntry failed: Cache Service Url not found, unable to restore cache.
βš™  ::set-output:: cache-hit=false
@cplee cplee added area/runner Relating to errors in the runner kind/bug Something isn't working labels Jun 23, 2020
@benwinding
Copy link

Happens with actions/cache@v1 too.

Seems that every test of a github action requires all npm modules to be installed....

Has anyone found a work around?

@rafilkmp3
Copy link

still searching anithin better than comment lines to use act

@quisse
Copy link

quisse commented Jul 31, 2020

The ACTIONS_CACHE_URL is missing.

@github-actions
Copy link
Contributor

Issue is stale and will be closed in 7 days unless there is new activity

@github-actions github-actions bot added the stale label Sep 30, 2020
@benwinding
Copy link

Any progress on this? seems to be linked to #329

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2021

Issue is stale and will be closed in 7 days unless there is new activity

@grische
Copy link
Author

grische commented Jan 18, 2021

I guess this can be tracked as part of #329

@BevanR
Copy link

BevanR commented Dec 7, 2021

Google search suggestions and results suggest that this is a popular topic and issue;

image

image

@BevanR
Copy link

BevanR commented Dec 7, 2021

If you are using nektos/act to develop GHA workflows locally and want to get actions/cache working so that you can get faster feedback when you test-run on your changes to GHA workflow yaml files;

  1. ACTIONS_RUNTIME_URL, ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL environment variables are missing.Β #329 is a dead end. Do not bother reading the long thread.
    • It is mostly about artifact upload/download actions, not cache actions.
  2. Disable cache actions with if: ${{ !env.ACT }}
  3. Use act's --reuse flag.

I will repeat that last step, because it is a much better solution than trying to get the cache action working locally;

Use act's --reuse flag

From the docs; -r, --reuse reuse action containers to maintain state

Cache saving and restoring becomes unnecessary.

@netaskd
Copy link

netaskd commented Dec 19, 2021

@BevanR in this case we have to set name: field the same for each jobs, that uses actions/cache. Otherwise it does not work...

@guice
Copy link

guice commented Jan 4, 2022

  1. Use act's --reuse flag.

I will repeat that last step, because it is a much better solution than trying to get the cache action working locally;

As @netaskd as informed us, this only works if each job has the same jobs.{id}.name: value, which, as you may expect, not ideal. It would be nice if --reuse reused the container for the whole workflow.

It seems --reuse keys on jobs.{id}.name for reuse.

Smart123s added a commit to Smart123s/FastLogin that referenced this issue Mar 13, 2022
act is a tool that let's users test GitHub Actions on a local machine,
but it doesn't support caching at the moment.
nektos/act#285 (comment)
Smart123s added a commit to Smart123s/FastLogin that referenced this issue Mar 13, 2022
act is a tool that let's users test GitHub Actions on a local machine,
but it doesn't support caching at the moment.
nektos/act#285 (comment)
@leumasme
Copy link

leumasme commented Jul 5, 2022

I am using a github action developed by someone else in my own action via uses. Their action includes actions/cache, causing act to fail. I do not need the cache for speeding up actions, is there a way to simply ignore the cache action in subactions to get act to work without having to modify the subactions?

@BevanR
Copy link

BevanR commented Jul 5, 2022

@leumasme --reuse may work in this scenario; You will still need to modify the sub-actions, but only temporarily to get it to install the cached dependencies once. Then, if the sub-action uses the cache correctly with an appropriate key, then it won't attempt to access the cache and will succeed.

@zhz125
Copy link

zhz125 commented Jul 8, 2022

I am using bazelisk. I used the exact yml (minus mount cache step) as provided by the website and I got the following errors. Any workaround or future support for bazel?

[Unit tests/test]   πŸ’¬  ::debug::*** zstd command line interface 64-bits v1.4.4, by Yann Collet ***
[Unit tests/test]   πŸ’¬  ::debug::getCacheEntry - Attempt 1 of 2 failed with error: Cache Service Url not found, unable to restore cache.
[Unit tests/test]   πŸ’¬  ::debug::getCacheEntry - Attempt 2 of 2 failed with error: Cache Service Url not found, unable to restore cache.
[Unit tests/test]   ❗  ::error::getCacheEntry failed: Cache Service Url not found, unable to restore cache.
[Unit tests/test]   ❌  Failure - Main bazelbuild/setup-bazelisk@v2
[Unit tests/test] exitcode '1': failure

@adrianruizmora
Copy link

adrianruizmora commented Feb 1, 2023

If you are using nektos/act to develop GHA workflows locally and want to get actions/cache working so that you can get faster feedback when you test-run on your changes to GHA workflow yaml files;

1. [ACTIONS_RUNTIME_URL, ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL environment variables are missing. #329](https://github.com/nektos/act/issues/329) is a dead end. Do not bother reading the long thread.
   
   * It is mostly about artifact upload/download actions, not cache actions.

2. Disable cache actions with `if: ${{ !env.ACT }}`

3. Use act's `--reuse` flag.

I will repeat that last step, because it is a much better solution than trying to get the cache action working locally;

Use act's --reuse flag

From the docs; -r, --reuse reuse action containers to maintain state

Cache saving and restoring becomes unnecessary.

As netaskd and guice have said you need to use the same name for each job that uses actions/cache. What i have done to make it more dynamic is to set the name of jobs like the following so i don't have to make changes to test locally or before pushing:

build:
    name: ${{ env.ACT || 'build' }} 
    ...
deploy:
    name: ${{ env.ACT || 'deploy' }} 
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runner Relating to errors in the runner kind/bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests