Snapcraft 7 doesn't update the apt-cache before marking packages to install

Hello

I’ve raised an issue upstream https://github.com/canonical/craft-parts/issues/292

It appears that in a docker container with a cleared cache, snapcraft will fall over because it can’t check for packages to mark for installation

thanks

Did you create this container image yourself, or is it a third party container image, or the official one from Canonical?

Note: the Canonical maintained image (named snapcore/snapcraft hasn’t been rebuilt/updated in over a year now so should be considered out of date). I maintain a more up to date image named diddledan/snapcraft with a few usage caveats, namely that you must run it in privileged mode (e.g. with --privileged when launching with Docker CLI) - ignore that the namespace is wrong, I changed my name and can’t update the docker hub namespace to match :sob:.

Hi yes this is an image that we have built and have been using similar images for the last year or 2 with previous versions of snapcraft. Our image works fine, it just took a long time to work out that the apt cache needed to be populated first which is strange as it does it’s own apt-get update right after the point where it had been failing.

+1 for this issue.

For CI we need to run snapcraft in docker. It worked fine in snapcraft-6, so it seems like a regression.

Cheers, Just

This is actually on purpose for faster iteration (no need to apt update every time you run).

That said, we could make the accommodation to detect docker or perhaps signalled through an environment variable

To clarify, core18 and core20 should maintain the behavior of what was on Snapcraft 6; the only change is if you manually change the base from those to core22.

I can see the speed advantage. But, for reliability you would want an update every time, as even an out of date apt sources cache can cause issues.

I would vote for it being configurable, although personally I would also vote for the default to the other way round [ reliability over speed ].

Cheers, Just

That doesn’t seem to be the case for us, core20 base snaps seemed effected too. That could be a bug at least :slight_smile:

Cheers, Just