nix-community / cache-nix-action

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

[BUG] Restoring cache appears to be missing files (e.g. libgcc_s.so.1) #44

Open obreitwi opened 2 weeks ago

obreitwi commented 2 weeks ago

Describe the bug

When building in a restored cache, the builder is unable to find libgcc_s.so.1.

This leads to various errors, such as:

/nix/store/00mg4vlhzmm7gi9bd5v5ydjlgrywpc3n-go-1.22.3/share/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 
/nix/store/bgcaxhhxswzvmxjbbgvvaximm5hwghz1-binutils-2.41/bin/ld: cannot find -lgcc_s: No such file or directory            
collect2: error: ld returned 1 exit status                                                                                  

when building a go service via gomod2nix or

closure-paths> python3: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory
error: builder for '/nix/store/gyb8h4dps65bbk6x6is9mxhg2akdv7vv-closure-paths.drv' failed with exit code 127

when building a docker image via dockerTools.buildLayeredImage.

To Reproduce

(Currently the error occurs in a private repo. I plan on re-creating it in a public repo for easier reproduction, but I wanted to report the issue first nonetheless)

Steps to reproduce would include:

  1. Run workflow successful with caching enabled (auto-optimize-store = false, sandbox = true), observe that all build targets get built successfully.
  2. Run the exact same workflow again with minor modifications to the source code or docker image contents, this time restoring the newly created crash.
  3. Observe one of the errors above, depending on which workflow was triggered.

Expected behavior

Restoring the cache should restore all files; to nix, it should not make a difference.

Additional context

A workaround is simply disabling the cache for now, but I want to understand what is going on… :wink:

deemp commented 2 weeks ago

@obreitwi, please verify that files are missing due to the cache-nix-action. There are two ways:

Files may be missing due to building an incorrect list of paths to exclude.

https://github.com/nix-community/cache-nix-action/blob/8351fb9f51c580c96c509987ebb99e38aed956ce/src/utils/action.ts#L83-L99

I'd be really nice if you provide a way to reproduce the problem, e.g., with a nixpkgs package.