Not able to start/configure custom built ubuntu core

I built a ubuntu core 18 image with additional gadget snap, but I get a following error when I am trying to configure system.

/usr/share/subiquity/console-conf-wrapper: line 13: snap: command not found
Press enter to configure.

If I proceed through config, after I type my email and press ENTER, I can see that there is a flash of error/exceptions and configuration wizard goes back to beginning.

I found that someone had a similar issue here: With custom kernel in AMD64 architecture, snap command not found , but there was no solution for this.

I used following repo to built my gadget “git clone” and I checked into branch 18

I edited snapcraft.yaml and added serial port configuration like this

version: '0.1.0'
type: gadget
base: core18
summary: PC gadget to scan QR code
description: |
    This gadget enables generic pc devices to work with Ubuntu Core
grade: stable
confinement: strict

    plugin: nil
      - grub-efi-amd64-signed
      - grub-pc-bin
      - shim-signed
    prime: [ -* ]
    source: .
      - grub-common
    plugin: make
    after: [grub-prepare]

    interface: serial-port
    path: /dev/ttyACM0

after this I built my image with a following command

sudo ubuntu-image snap --channel stable --snap qrscanner_0.1.0_amd64.snap pc-mine.model

where pc-mine.model looks like this:

authority-id: canonical
series: 16
brand-id: canonical
model: ubuntu-core-18-amd64
architecture: amd64
base: core18
display-name: Ubuntu Core 18 (amd64)
gadget: pc=18
kernel: pc-kernel=18
timestamp: 2018-08-13T09:00:00+00:00
sign-key-sha3-384: 9tydnLa6MTJ-jaQTFUXEwHl1yRx7ZS4K5cyFDhYDcPzhS7uyEkDxdUjg9g08BtNn


#ubuntu-image --version
ubuntu-image 1.7+snap1
#snapcraft --version
snapcraft, version 3.8

What am I doing wrong? I assume that there is something wrong with my gadget, because when I built this new image without it, I can boot and configure new system without any problems.

Kind regards,

this looks like the seeding of snap packages (specifically snapd) did not happen on first boot …

try changing brand-id and authority-id to match the actual signing key in your model and try again …

also, if you have a local gadget snap you need to use an additional --snap /path/to/gadget.snap in your ubuntu-image call

I added my gadget snap with “–snap qrscanner_0.1.0_amd64.snap”

sudo ubuntu-image snap --channel stable --snap qrscanner_0.1.0_amd64.snap pc-mine.model

Hmm what do you mean by "try changing brand-id and authority-id to match the actual signing key in your model and try again " ?

I generated this assertions from a running ubuntu core 18. I guess I missing sth.

I also read this doc:
Do I really have to use my acount-id and use singing key that I generated ? Is it necessary to build custom local image ?

oops, by the name i was assuming its an application snap :slight_smile: (you need to put the correct name into your model: gadget: qrscanner )

the key needs to match the ids, else seeding fails …

1 Like

Hmm I built it again with my account-id and I signed it with my key and still I have the same error:

My new model looks like this:

authority-id: Hc**********
series: 16
brand-id: Hc*************
model: terminal-ubuntu-core-18-amd64
architecture: amd64
base: core18
display-name: Ubuntu Core 18 (amd64) - mine
gadget: pc=18
kernel: pc-kernel=18
timestamp: 2019-11-14T11:07:00+00:00
sign-key-sha3-384: 3mV13An6zvK4tgsu2Z************  

I still think that there is an issue with this gadget, during boot I noticed that system is stuck for a minute on:

[ OK ] Mounted Mount unit for pc, revision 36
Prepare snap “/var/lib/snapd/seed/snaps/qrscanner_x1.snap” (unset)

and then it disappears and only shows

Unmouting Make snapd snap tooling available for the system....
[ OK ] Umounted Make snapd snap tooling available for the system.
[ OK ] Started Start the snapd services from the snapd snap.
[ OK ] Started Ubuntu Core Firstboot Configuration tty1.

Is it possible to check logs somewhere ? I mounted disk containing this booted OS and I couldn’t find any logs.

you still dont have the proper gadget entry in your model … so the system tries to install two gadgets here … the “pc” one and “qrscanner”, this indeed fails …

logging has sadly been fully moved to journald in core18, so there is no way to get debug logs prior to having a fully booted system nowadays

1 Like

I wonder if we should make snap prepare-image fail to create a seed when you specify more than one gadget snap in an image. It seems clear that snapd is failing on this when trying to boot the seed, but perhaps we should add a case when building the seed too.

1 Like

That definitely makes a lot of sense, though do you know in advance that a snap added by --snaps but not in the model is of type gadget ?

Well we already do checks like if a snap has a base and that base is in the seed, so we have all the information to see that there are two gadgets. We wouldn’t probably check that the snap specified in --snap is a gadget, we’d just look at the full list of snaps from the model, command line arguments, etc and if we have two gadgets bail.

1 Like

Oh, you are right. I somehow thought that there can be more than one gadget snap. When I specify only my gadget name in my model, it builds and boots. Thank you.

1 Like

@ogra One more question, I was able to connect my snap to interface provided by this gadget. As you saw it was a serial interface, but I get denied by apparmor.

16.277054] audit: type=1400 audit(1573746595.092:31): apparmor=“DENIED” operation=“capable” profile=“snap.terminal-app.terminal-kiosk” pid=1893 comm=“terminal” capability=23 capname=“sys_nice”
[ 16.611495] audit: type=1400 audit(1573746595.433:32): apparmor=“DENIED” operation=“file_lock” profile=“snap.terminal-app.terminal-kiosk” name="/dev/ttyACM0" pid=1831 comm=“terminal” requested_mask=“k” denied_mask=“k” fsuid=0 ouid=0
[ 16.934880] audit: type=1400 audit(1573746595.761:33): apparmor=“DENIED” operation=“capable” profile=“snap.terminal-app.terminal-kiosk” pid=1831 comm=“ThreadPoolForeg” capability=23 capname=“sys_nice”

Should it be like this if I access this device via gadget ?

@pstolowski @jdstrand here’s another case of file locking on a serial port device node being denied :thinking:

1 Like

are you root when running the app ? (device permissions are not overridden by adding an interface, it is likely the /dev/ttyACM0 device node is only accessible by root … )

@ogra IIUC this means it’s being run as root and the object being access is also owned by root

oh, i’m blind ! :sunglasses:

Thanks for spotting, that at least confirms that problem is not unique to hotplug and we may be simply missing this permission for some use cases.

Yeah I’m leaning towards thinking we should just add that permission to the rules

I assume that is a bug ? So is there a work around for this ? Can I just add additional apparmor rule manually ?

Or maybe building app in classic or devmode enabled will help ?

no need to build it with --devmode, but installing it manually with the --devmode flag should work … classic snaps are not option on ubuntu core (they are refused installation)

1 Like