Open basak opened 1 month ago
Further context: I found this when trying to move the git-ubuntu snap to core24. That's complex enough so I came up with a minimal reproducer. The minimal reproducer didn't require me to actually stage any packages from the apt repository, since it fails before that stage, so I just used an arbitrary repository I have around.
I think this isn't blocking git-ubuntu since it's built in CI in destructive mode and I can probably use sudo there without problems (I haven't tried yet), but I'll leave a link to this issue in my workaround.
Further, if I drop the package-repositories
key, then the same production steps fail with: Error installing snap 'core24' from channel 'latest/stable'.
unless I use sudo. Speculation: this seems to be another symptom of the same bug.
Hi @basak,
I think the problem is with the documentation. It doesn't explain the expectations for the environment where Snapcraft can run in destructive mode.
Building core20 and older snaps in destructive mode would detect if sudo
needed to be used for most operations. Starting in core22, this was dropped. Now, the burden of setting up the environment so there are permissions to do things like install snaps, packages, apt repositories falls on the user. Most environments where destructive mode is used run as root.
I updated the documentation https://snapcraft.io/docs/build-options to be more clear.
Thanks @mr-cal that's very helpful!
I have a couple of suggestions:
snapcraft --destructive-mode
should just fail immediately if it's not root then? That would really help with development and debugging, rather than seeing an error message that doesn't make the failure reason obvious. I appreciate that perhaps there might be a few cases where it would work anyway, but it doesn't seem worth it to me to support that for the downside of hiding the root cause as a consequence, but I leave that to your judgement.lxd init
needs automating, lxd needs to download an additional image every time, etc. I can do these things, but getting something to work automatically in a remote environment for the first time is always time consuming. Would you consider changing your recommendation stating that it's OK to do in a fresh VM please? Or do you plan to drop --destructive-mode
in the future entirely?
Bug Description
If I run
snapcraft --destructive-mode
, it fails.To Reproduce
On a fresh Noble VM:
Expected results: success Actual results:
Unknown error: Failed to install GPG key: Full execution log: '/home/ubuntu/.local/state/snapcraft/log/snapcraft-20241013-093507.964064.log'
Environment
Ubuntu 24.04 cloud image, snapcraft in destructive mode. Snapcraft snap 8.4.3 (12823).
snapcraft.yaml
Relevant log output
Additional context
On the other hand,
sudo snapcraft --destructive-mode
works. But the requirement for this isn't documented anywhere (eg. no mention at https://snapcraft.io/docs/build-options where--destructive-mode
is documented). I assume this requirement is not intended? Otherwisesnapcraft --destructive-mode
should simply fail to run immediately.This seems to be a regression between base: core20 and base: core24.