Snapcraft produces correct build only with remote-build

Hello fellow users,

I’ve been puzzled by this error for quite few days and I decided to reach the forum for advice.

I am trying to build a snap for my Golang app using the standard snapcraft command. The snap is intended to run on my Raspberry Pi Zero 2W which runs Raspbian based on Debian 11 with 6.1.21-v8+ kernel. On the snapcraft.yaml file I have declared the architectures:

  - build-on: amd64
    build-for: arm64

Running the snapcraft command works and produces the .snap file which installs on the Pi correctly however upon running the command I get cannot snap-exec: cannot exec "/snap/[...]": exec format error.

Interestingly, running snapcraft remote-build with the same snapcraft.yaml produces a snap as well which runs perfectly fine on the Pi.

Am I missing something here? I need to install something extra to make local builds work?

Thanks in advance!