Snapcraft push error: "KeyError: 'architectures'"

Hey guys,
We are trying to push our application to the snap store for the first time and are running into errors with snapcraft push.

The app is an electron app that is packaged using electron-builder with snap. We successfully end up with a built myapp_0.0.1_amd64.snap file from electron-builder.

We have registered our app name with the snap store.

Whenever I try to push the app with snapcraft push myapp_0.0.1_amd64.snap I get the following:

$ snapcraft push myapp_0.0.4_amd64.snap
Pushing myapp_0.0.4_amd64.snap
Preparing to push '/home/me/app/dist/myapp_0.0.4_amd64.snap' to the store.
Traceback (most recent call last):
  File "/snap/snapcraft/1094/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.39', 'console_scripts', 'snapcraft')()
  File "/snap/snapcraft/1094/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 565, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/snap/snapcraft/1094/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/snap/snapcraft/1094/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/snap/snapcraft/1094/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/snap/snapcraft/1094/lib/python3.6/site-packages/snapcraft/cli/__main__.py", line 43, in <module>
    run(prog_name='snapcraft')
  File "/snap/snapcraft/1094/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/1094/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/1094/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/1094/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/1094/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/1094/lib/python3.6/site-packages/snapcraft/cli/store.py", line 149, in push
    snapcraft.push(snap_file, channel_list)
  File "/snap/snapcraft/1094/lib/python3.6/site-packages/snapcraft/_store.py", line 481, in push
    arch = snap_yaml['architectures'][0]
KeyError: 'architectures'

What happens if you add architectures: [amd64] to your snapcraft.yaml?

electron-builder seems to be producing a snap without an architectures key (I don’t believe it uses snapcraft to do this). Since snapcraft is used to creating the snaps and it always puts one in there, it seems to be assuming that it’s in there. @chipaca is it valid to have a snap.yaml with no architectures?

yes, a missing architectures field is equivalent to ["all"].

(which electron snaps almost certainly are not)

Indeed. @kspearrin the failure to push is a bug in snapcraft, but there’s also a bug in electron-builder-- the snaps it’s producing are claiming to be compatible with all architectures (armhf, arm64, amd64, etc.).

don’t forget ppc64el!

And s390x. And there’s another one in there… gosh. i386? Nah…

Here’s the fix for Snapcraft: https://github.com/snapcore/snapcraft/pull/1937 .

I opened an issue with electron-builder here: https://github.com/electron-userland/electron-builder/issues/2596

electron-builder uses snapcraft pack to produce snap from prebuilt template (no one can wait 5-20 minutes to build snap and build only on Linux). I will fix generated snap.yml for this case today.

2 Likes