awalsh128 / cache-apt-pkgs-action

Cache APT packages in GitHub Actions
Other
205 stars 35 forks source link

tar Cannot stat: No such file or directory #99

Closed iver56 closed 1 year ago

iver56 commented 1 year ago

Hi,

I'm using cache-apt-pkgs-action (thanks for making it, by the way) like this:

    - uses: awalsh128/cache-apt-pkgs-action@latest
      with:
        packages: libsdl2-dev build-essential gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu ffmpeg
        version: 1.0

Lately it has been failing. The log ends like this:

10:20:18 Caching 153 installed packages...
10:20:18   * Caching libnss-systemd to /home/runner/cache-apt-pkgs/libnss-systemd:249.11-0ubuntu3.7.tar...
10:20:18     done (compressed size 320K).
10:20:18   * Caching libsystemd0 to /home/runner/cache-apt-pkgs/libsystemd0:249.11-0ubuntu3.7.tar...
10:20:18     done (compressed size 812K).
10:20:18   * Caching systemd-sysv to /home/runner/cache-apt-pkgs/systemd-sysv:249.11-0ubuntu3.7.tar...
10:20:18     done (compressed size 32K).
10:20:18   * Caching libpam-systemd to /home/runner/cache-apt-pkgs/libpam-systemd:249.11-0ubuntu3.7.tar...
10:20:18     done (compressed size 492K).
10:20:18   * Caching systemd to /home/runner/cache-apt-pkgs/systemd:249.11-0ubuntu3.7.tar...
tar: lib/systemd/system/system-systemdx2dcryptsetup.slice: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
Error: Process completed with exit code 123.

I have tried both latest (v1.2.4) and v1.2.1, and I get the same error in both cases. I have also tried execute_install_scripts: true

What can I do to resolve the issue?

awalsh128 commented 1 year ago

Can you turn on debug from the latest version and link to the logs?

It is pulling in systemd as a dependency. It will try to tar all files in the APT manifest. For some reason that file is listed but not present on disk. We need to find out why that file isn't present. Once we know more we can either fix it per package or maybe accommodate in general (i.e. throw a warning and continue with Tar).

I can get around to this but it may take me some time as I have been fairly busy recently. Something that would help a lot would be to install that version of systemd and see if the file is there, and try to explain the behavior.

iver56 commented 1 year ago

Yes, certainly. I'll try to make a minimal repo for reproducing it.

One thing I noticed in the log is that lib/systemd/system/system-systemdx2dcryptsetup.slice doesn't have a slash in the beginning. Could that be it?

iver56 commented 1 year ago

I have created the minimal repo that reproduces the issue. It uses @latest version and debug: true

The failed job, along with the debug log can be read here: https://github.com/iver56/cache-apt-systemd/actions/runs/4374423862/jobs/7653831648

awalsh128 commented 1 year ago

Thank you very much and the coffee 😁 The path will be relative intentionally because this is what Tar accepts only. I have it restore to root.

I hope you have an update sometime today.

iver56 commented 1 year ago

Thank you very much and the coffee 😁

You're welcome 😄

I hope you have an update sometime today.

What kind of update from me do you want/expect? You mentioned "install that version of systemd and see if the file is there" earlier. Is that on me or you? How would one begin to reproduce it? Make a docker image where that version of systemd gets installed?

awalsh128 commented 1 year ago

This is on my end. You don't need to do anything more.

I think I see what the issue is. The filename is using a backslash in it.

$ ls /lib/systemd/system/system-*
'/lib/systemd/system/system-systemd\x2dcryptsetup.slice'

Enclosed the filepath in single quotes and it was able to store and extract successfully.

$ tar -cf /tmp/test.tar '/lib/systemd/system/system-systemd\x2dcryptsetup.slice'

Working on a fix. Still need to clear some failing tests in master.

awalsh128 commented 1 year ago

Was able to clear up the errors and the regression test for this is now passing.

You can try out the pre-release v1.3.0. Will do the final release later today (PST).

iver56 commented 1 year ago

Thanks! It seems to be working well on my end

iver56 commented 1 year ago

I'm not sure what happened or why, but I am now seeing this error once again, even with v1.3.0. I made a minimal reproduction here: https://github.com/iver56/cache-apt-systemd/actions/runs/4675789547/jobs/8281303920

Do you need me to enable debug mode as well?

awalsh128 commented 1 year ago

Wow, sorry to hear that. The regression isn't failing either. Does rolling back the version fix it? A debug run would be helpful.

I noticed it failing on the same file but the backslash is gone which indicates some regression in my part. Try the run against master too in your action version as ...@master

iver56 commented 1 year ago

I tried v1.2.4 again, and that did not help: https://github.com/iver56/cache-apt-systemd/actions/runs/4686324193/jobs/8304282868?pr=3

Here is v1.3.0 with debug mode set to true: https://github.com/iver56/cache-apt-systemd/actions/runs/4686331941/jobs/8304299856?pr=4

And with @master: https://github.com/iver56/cache-apt-systemd/actions/runs/4686348280/jobs/8304335659?pr=5

awalsh128 commented 1 year ago

Looks like the CI silently ate the error, which is why I didn't catch it originally.

echo "lib/systemd/system/system-systemd\x2dcryptsetup.slice" | xargs -I '{}' echo \'{}\'

Not sure how this ever worked actually as it was the only change https://github.com/awalsh128/cache-apt-pkgs-action/commit/a644619d1f0e6b19aadae0ce5ef7fea7cacdf9f3. Looks like xargs string substitution doesn't preserve the literals still.

Will work on an actual fix, then doublecheck on the CI and update here.

awalsh128 commented 1 year ago

Updated the CI regression test (old run log) with an updated version to see if it will trigger the error (https://github.com/awalsh128/cache-apt-pkgs-action-ci/commit/f94c31857f701c00a791b10d56df84dc457398ec). systemd makes this a bit awkward because it is a core level dependency on top of the OS. The alternative would be to mount these Ubuntu images locally and run the tests inside of it before commit.

@iver56 do me a favor and run the action from the dev branch. I am using awk instead in https://github.com/awalsh128/cache-apt-pkgs-action/commit/abb3a6d0e72d275062b894c8be615430ad9c519c and https://github.com/awalsh128/cache-apt-pkgs-action/commit/bf94842250ec22d903842300bb32481839df844e. Hoping this will be a better fit overall anyways since it is a text processing tool.

UPDATE: Actually hold off, looks like the change broke some other tests.

awalsh128 commented 1 year ago

Actually give it a shot. It is just do a package version not existing which I just need to debug on the CI end.

iver56 commented 1 year ago

@dev: https://github.com/iver56/cache-apt-systemd/actions/runs/4718674827/jobs/8368542095 @dev with debug: true: https://github.com/iver56/cache-apt-systemd/actions/runs/4718697907/jobs/8368592951

iver56 commented 1 year ago

Feel free to fork that cache-apt-systemd repo if you want to do test runs like that more quickly than what I can provide

awalsh128 commented 1 year ago

Sorry for the delay. I'll check it out this weekend.

sn-o-w commented 1 year ago

@awalsh128 Hi there. I also get a very similar error:

tar (grandchild): lzip: Cannot exec: No such file or directory

And yes, lzip is set to get installed via the workflow. 😞

sn-o-w commented 1 year ago

Hmm, in my case, lzip seems to not be installed properly via cache-apt-pkgs-action. I wonder why. 🤔

sn-o-w commented 1 year ago

@iver56 I think I have fixed it: https://github.com/sn-o-w/cache-apt-systemd/actions/runs/5547482021/jobs/10129187070

We need this for the dev branch: https://github.com/sn-o-w/cache-apt-pkgs-action/commit/d0ee83b497ac30023e51cd526c62e57b07501912

You can temporarily use sn-o-w/cache-apt-pkgs-action@master

iver56 commented 1 year ago

Good work :) I have not tested it, but if it's a good fix, maybe it can be fixed upstream too?

bekriebel commented 1 year ago

I started getting this same issue with the caching of systemd. Using @sn-o-w's branch fixes the issue.

iver56 commented 1 year ago

@awalsh128 Any chance @sn-o-w's fix can get merged upstream?

vvv commented 1 year ago

Got this error tonight. @an-o-w's patch works.

awalsh128 commented 1 year ago

Hi all. Lots of apologies for the massive delay. I updated the doc looking for help with maintainers (if any of you are feeling up to it).

I integrated the fix and confirmed it works against the regression test on the CI (log). It is now available in release v1.3.1 and marked against latest tag.

@iver56, @vvv and @sn-o-w, please confirm for yourself before I close this out.

iver56 commented 1 year ago

No need to apologize. I know the feeling. Thanks for merging, testing and releasing the fix! ❤️🥇

I just tested it, and it runs smoothly as far as I can tell. Now I can get fast CI runs again :D

sn-o-w commented 1 year ago

@awalsh128 👍

vvv commented 1 year ago

@awalsh128 It works! 🙌🏻 Thank you.