Build snap with base core20

I would like to build/install a snap with “core20” base. I have the “core20” snap installed on my system but I don’t have the “core” snap installed. Do I need it? Is it mandatory?

Thank you.

Snapd will automatically install the core snap if it is needed by any snaps, so unless you are running a really old version of snapd from your distro’s packages (roughly older than 2.40), you do not need to install the core snap manually.

If you can provide the output of snap version and snap list we can say for sure if your version of snapd is new enough to not need the core snap installed

Hi everyone, I’m trying to build a snap with “base:core20” in the snapcraft.yaml. Is it mandatory to have the “core” snap installed on my system?

I merged your other post to this one as well since it’s the same question

These are the output of the commands:

snap    2.53.4
snapd   2.53.4
series  16
kernel  5.4.0-1048-raspi

and

core20          20211129       1274   latest/stable  canonical✓  base
pi              20-1           97     20/stable      canonical✓  gadget
pi-kernel       5.4.0-1048.53  377    20/stable      canonical✓  kernel
snapd           2.53.4         14296  latest/stable  canonical✓  snapd

The problem for me is that I don’t have an internet connection in this system. Consequently, my snap cannot download and install the “core” snap.

Ah are you running Ubuntu Core? Are you trying to install the snap on Ubuntu Core or are you trying to build the snap on Ubuntu Core?

Yes, exactly. I’m using Ubuntu Core.

I’m trying to do both installing and building on Ubuntu Core. Is that possible?

I would not suggest trying to build natively on Ubuntu Core, it is more complicated that building on a classic image. So you have two options:

  1. build on another, classic image with snapcraft
  2. Install the lxd snap on your Ubuntu Core image, and then launch a focal LXD container and install snapcraft inside that lxd container, and then to build the snap run snapcraft --destructive-mode to prevent snapcraft from trying to launch a VM/container that it manages.

That’s interesting. So, I can write a snapcraft.yaml like

architectures:
  - build-on: amd64
    run-on: arm64

and build on an Ubuntu Server (on a arm64 architecture or an amd64 architecture?). Then I can transfer the snap on Ubuntu Core and install it?

Can you explain me a little bit more about the first option?

That would only work if you have setup your snapcraft.yaml to cross-build, it does not happen automatically.

What I was describing is using another arm64 machine running classic Ubuntu, i.e. another Raspberry Pi, or some other arm64 machine.

I managed to correctly build the snap with lxd and --destructive-mode. Thank you!

Just out of curiosity, if I use the first method, Raspberry get stuck on this for a while:

go install -p 4 -ldflags -linkmode=external ./...

and then prompts me this error:

go build github.com/aws/aws-sdk-go/service/iot: /snap/go/8843/pkg/tool/linux_arm64/compile: signal: killed
Error: websocket: close 1006 (abnormal closure): unexpected EOF

Do you happen to know why this happens?

My best guess is either Go ran into an issue downloading something or it ran out of memory trying to compile things. The fact that it is talking about websockets implies it’s the former though

That’s strange because the connection is working. I’m leaning to the second option…