Error preparing image base "core" has unexpected type os

Creating a new model assertion which includes “core” because “pciutils” snap requires it. I added it to the my-model.json using the following source code:

,
        {
            "name": "core",
            "type": "base",
            "default-channel": "latest/stable",
            "id": "99T7MUlRhtI3U0QFgl5mXXESAiSwt776"
        }

The type is set to base, since the link below states that core22, core20, core18, core, & bare are all base snaps.

However, when I attempt to build the image I get the following error:

Error: Error preparing image: base "core" has unexpected type: os

Here is the screenshot:

To get it to build I need to change the type from base to core and it looks like this:

,
        {
            "name": "core",
            "type": "core",
            "default-channel": "latest/stable",
            "id": "99T7MUlRhtI3U0QFgl5mXXESAiSwt776"
        }

Why doesn’t it work as type set to base? Is there a command similar to snap info ... that I can run to determine which type it is supposed to be?

You have to remember that the base snap, is the base of which you to “base” your OS image off, so basically, core20, or core22 as a operating system base.

The only reason it is defined as a base, is that if you want a specific channel of core20 as a OS base, you could define the channel, etc… That’s why ubuntu-image complains about the component “os”, because it does not understand why the extra “os” section, which is the OS itself.

You only want the libs of core(16), not the whole core(16) os “base”… See here: https://ubuntu.com/core/docs/reference/assertions/model

Check the “base” keyword and the “type” keyword… Hope this answers your question?

@ruhan.vanderberg , for some reason when I was building before, it would not allow me to add pciutils without also adding core Snap. This is why I was running into this issue. This is the error I was getting:

Error: Error preparing image: cannot add snap "pciutils" without also adding its base "core" explicitly

I had to change the type from base to core to get the build to finish without failing. However, when I tested the image, it would never boot.

A few days went by and I updated my Linux machine and now it builds with pciutils and it doesn’t asking error out stating it needs core Snap.

Something must have changed because the author of pciutils changed recently. Maybe the Snap got some updates to it.