nix-community / cache-nix-action

Cache Nix store in GitHub Actions to speed up workflows [maintainer=@deemp]
MIT License
34 stars 7 forks source link

Error: failed to restore #9

Closed hissssst closed 5 months ago

hissssst commented 1 year ago

Whole restore step is filled with errors like this. Action is set up just like in example in the docs

/usr/bin/tar: ../../../../../nix/store/h5c0n2pcidaikpm6pwm8v9hz81ndmppj-aws-sdk-cpp-1.11.37/lib/libtesting-resources.so: Cannot open: File exists
/usr/bin/tar: Exiting with failure status due to previous errors
Warning: Failed to restore: "/usr/bin/tar" failed with error: The process '/usr/bin/tar' failed with exit code 2
Cache not found for input keys: nix-f69b52731a4e03acd9238e5c4b0e1db653f46d92e3a380bab33c5ab7c53f0155, nix-f69b52731a4e03acd9238e5c4b0e1db653f46d92e3a380bab33c5ab7c53f0155

Doc says that it's okay, but my nix develop command still downloads all the packages

hissssst commented 1 year ago

@deemp ping

deemp commented 1 year ago

@hissssst, I'm traveling. Please, share a link to your repo. If you can't, please, try to reproduce this problem in another repo and share a link.

deemp commented 1 year ago

I'll close this issue until there's more context.

hissssst commented 1 year ago

@deemp reopen it please and do not close it unless significant time passes or we resolve the issue. You can't just close an issue if someone didn't respond during the weekend

deemp commented 1 year ago

@hissssst, I didn't know about this GH feature.

you cannot reopen your own issues if a repo collaborator closed them.

I expected that you'll reopen this issue when you can provide more context.

I'll reopen the issue.

hissssst commented 1 year ago

@deemp I've created open source project where this error is reproduced https://github.com/hissssst/nebulex_adapters_ecto

deemp commented 1 year ago

@hissssst, you saved an incomplete cache and didn't update it later.

https://github.com/hissssst/nebulex_adapters_ecto/actions/runs/5881194692/job/15949164691#step:23:36

If you look at the workflow in the cache-nix-action repository, you can see that I purge old caches just before saving a new cache.

https://github.com/nix-community/cache-nix-action/blob/166176cf2e94f44f6451b0cd2c5f5abf55dfde16/.github/workflows/ci.yaml#L109

Currently, purge-cache is a separate action, but I'll probably include it into the cache-nix-action.

hissssst commented 1 year ago

@deemp purge-cache action didn't help in my private project. The same error persists

deemp commented 1 year ago

How did you check it's not your error? BTW, I integrated purge-cache into cache-nix-action. See https://github.com/nix-community/cache-nix-action#purge-old-caches

deemp commented 1 year ago

If you try the latest version of cache-nix-action, please, provide the logs of cache-nix-action (the first and the post phases).

deemp commented 9 months ago

@hissssst, now, there's usually no overwriting due to --skip-old-files

https://github.com/nix-community/cache-nix-action/blame/317362693c54649457bbaa0e5fe20df5f6c638ec/src/utils/action.ts#L79

A tar command looks like this

/usr/local/bin/gtar -xf /Users/runner/work/_temp/692c618e-65d6-4229-a8d8-7c11ee882599/cache.tzst -P -C /Users/runner/work/cache-nix-action/cache-nix-action --delay-directory-restore --skip-old-files --use-compress-program unzstd

However, errors occur sometimes on macOS (see https://github.com/nix-community/cache-nix-action/issues/24)

deemp commented 6 months ago

Currently, existing /nix/store paths are skipped when restoring a cache (link).

deemp commented 5 months ago

@hissssst, I made several releases since September. They may have solved your problem, so I'm closing this issue. Feel free to create new issues if there are any problems with cache-nix-action.