Reinstall when snap is required by custom core20 manifest

In the case of a customized core16 model that includes a preinstalled snap, one was able to run snap remove ... followed by snap install ... to provide a clean installation. With core20 and the same scenario the result of snap remove ... reports error: cannot remove "my-snap": snap "my-snap" is not removable: snap is required. Is there any way to force a clean re-installation of a snap that is required in core20?

If the model definition says the snap is required, then no you can’t remove it.

If the model definition lists the snap as presence: optional, then it will be preinstalled but removable.

You could set up your device to take a snapshot when the device is initially seeded/booted, and then use snap restore <id> to reset the state of the snap without re-installing it.

I just built an image with one snap’s presence set to optional, and after the image is seeded and booted up, the snap was not installed. Double checked the outputs of ubuntu-image, the snap was not included. I’m using golang version of ubuntu-image. I can install the snap after booted up. The assertion grade is secured.

You’ll need to pass --snap name-of-optional-snap to ubuntu-image to have the optional snap included on the image. I tripped over this one when first trying to use the feature too.

1 Like