My snapcraft CI started failing (PPA-dependency?)


I had an Ubuntu-18.04 CI lane building snaps without issues, until suddenly it started failing with this error:

Err:21 bionic/main amd64 libxml2-utils amd64

[3862]( 404 Not Found [IP: 80]

[3863]( 3532 kB in 0s (14.5 MB/s)

[3864]( Failed to fetch 404 Not Found [IP: 80]

The attempt to install this package is not actually done by my script, but by the snapcraft command itself. Why does snapcraft depend on some PPA that might stop existing?

Full log for the failed build:
Full log for the previous build that worked:

That PPA seems to be coming from the GitHub Actions base image: mentions “PHP 7.1 (PHP (cli) (built: Mar 20 2020 13:57:43) ( NTS ))”. So their image is called “ubuntu18” but also includes a bunch of non-Ubuntu things, which is a bit confusing.

Given the specific error and the fact that the libxml2 was last updated in that PPA on 2020-05-06, it looks like apt update hasn’t been run inside that image for more than a week. Launchpad assumes that apt update is run on at least the daily cycle that Ubuntu defaults to, so it removes old packages after a day or two. This is arguably something that GitHub should do, but you can also probably work around it by ensuring apt update is run before snapcraft.

But do be aware that, as described above, the GitHub images seem to be quite dirty and won’t necessarily generate the result that you expect.

The root cause is likely that you’ve missed an apt-get update call in your workflow. The GH Actions runners are spun up from an image that could be weeks old with a stale apt package list. In this case, a PPA configured in the image published out a new libxml2 package, causing the old version to become unpublished. An apt-get update call would let it find the new package. Note that this problem isn’t specific to PPAs: I’ve seen it happen for cases where the package list for the official bionic-updates repo was out of date.

If you want to build and publish snaps more easily from a Github Actions workflow, perhaps consider using the snapcore/action-build@v1 and snapcore/action-publish@v1 actions?

The build action uses LXD to build your snap, so avoids some of the weirdness present in Github’s VM images. To get the most out of it, you’d probably need to update your snapcraft.yaml file a bit to have the software build run by Snapcraft though. At present, it looks like you’re relying on assets built before running Snapcraft.

Thanks guys, it seems in fact that a simple apt update at the beginning of the CI recipe fixed it.

Thanks for the suggestion about using snapcore actions, but actually I’d prefer to move out from GithubCI to use GitLabCI (but I got a problem with the latter that hopefully I’ll fix soon, with the help of this forum… I’ll open another thread for that).