Error when I'm tryng to snap a webapp with electron

Hi

I’m trying to create a small webapps following the tutorial https://tutorials.ubuntu.com/tutorial/snap-a-website

This is how my snapcraft.yml looks like

name: framapiaf

base: core18

version: '0.1'

summary: Pouet on Mastodon with Framapiaf

description: |
  Framapiaf is a Mastodon instance

grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

parts:
  electron-app:
    source: app/
    plugin: nodejs

    stage-packages:
      - libnotify4
      - libappindicator1
      - libxtst6
      - libnss3
      - libxss1
      - fontconfig-config
      - gconf2
      - libasound2
      - pulseaudio

    after:
      - desktop-gtk2

    build: node_modules/.bin/electron-builder

    install: |
      mkdir $SNAPCRAFT_PART_INSTALL/app
      mv dist/linux-unpacked/* $SNAPCRAFT_PART_INSTALL/app

    prime:
      - -node_modules

apps:
  framapiaf:
    command: env TMPDIR=$XDG_RUNTIME_DIR desktop-launch $SNAP/app/framapiaf
    plugs:
      - home
      - x11
      - unity7
      - browser-support
      - network
      - gsettings
      - pulseaudio
      - opengl

and this is the error message:

snapcraft build
The snap/ directory is meant specifically for snapcraft, but it contains the following non-snapcraft-related paths, which is unsupported and will cause unexpected behavior:
- .snapcraft.yaml.swp

If you must store these files within the snap/ directory, move them to snap/local/, which is ignored by snapcraft.
Launching a VM.
The snap/ directory is meant specifically for snapcraft, but it contains the following non-snapcraft-related paths, which is unsupported and will cause unexpected behavior:
- .snapcraft.yaml.swp

If you must store these files within the snap/ directory, move them to snap/local/, which is ignored by snapcraft.
Failed to load plugin: properties failed to load for electron-app: Additional properties are not allowed ('build', 'install' were unexpected)
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.
An error occurred when trying to execute 'sudo -i snapcraft build' with 'multipass': returned exit code 2.

According to the tutorial:

Build and post-build instructions
Then we need to provide the following information:

The command (or commands) to build the app:
Since we are using electron-builder, simply calling electron-builder in the project will pick up details from our package.json file and generate an executable.
What to do with the result of our build:
The result of running electron-builder is a app/dist/linux-unpacked/, this is what we want in the snap, in a dedicated app/ directory for consistency.
What to package (and in our case, what not to package):
To ensure the snap package doesn’t contain unnecessary files, we tell snapcraft to trim what it pulls into the snap and exclude app/node_modules/, which only contains build dependencies.

So can you help me to understand what I’m doing wrnog ?

Cheers,
Winael

you have a vim swap file in the source dir, remove it (save and close all open vim instances in which you have snapcraft.yaml open, then rm .snapcraft.yaml.swp (if it still exists), then try calling snapcraft again)

Hi @ogra

How are you ? Happy new year :slight_smile:

The .snapcraft.yml.swp is not the cause of the issue. The issue is looged with the last three lines.

I run snapcraft build command this time with the snapcraft.yml closed:

Launching a VM.
2019-01-14T06:01:02Z INFO Waiting for restart...
core 16-2.36.3 from Canonical✓ installed
snapcraft 3.0.1 from Canonical✓ installed
core18 18 from Canonical✓ installed
Failed to load plugin: properties failed to load for electron-app: Additional properties are not allowed ('build', 'install' were unexpected)
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.
An error occurred when trying to execute 'sudo -i snapcraft build' with 'multipass': returned exit code 2.

As you see, it failed to load plugins, saying the properties build and install are not allowed for the electron-app part, but the tutorial talk about it The tutorial was based on Ubuntu 16.04 LTS and use cleanbuild command to build snap, that launches a LXC container. But now with Ubuntu 18.04 LTS, it seems that we can use a base keyword, with is set to core18 in my snapcraft.yml and the build is done with multipass.

So maybe I have to adapt things to be able to build my snap ?

Thx

The tutorial is outdated. It needs to be updated for snapcraft 3.x and bases. Could you please file an issue on the bug tracker (linked from every tutorial) at https://github.com/canonical-websites/tutorials.ubuntu.com/issues so we can track this. Thanks!

1 Like

as popey said, the “build” and “install” snippets have been renamed (well, install has actually been removed completely) … instead of build: you want to do something like:

    override-build:
       # script stuff to run before the build
       snapcraftctl build
       # script stuff to run after the build (i.e. install stuff)

I would propose we remove that tutorial because it’s now completely different from how I’d recommend making an electron app these days. Aside from the questionable value in making an electron app wrapper of a website in the first place.

These days I’d just use electron-builder and have it build a snap electron-builder -l snap rather than call snapcraft at all. electron-builder knows how to build snaps without being given a snapcraft.yaml at all.

See this blog post for details. https://snapcraft.io/blog/bringing-electron-applications-to-linux

1 Like

Hi @popey

Thx for your answer. I’ll try with this process then.

For the questionable value in making an electron app wrapper of a website, it’s very simple. Having my professional tools (bitbucket, rocketchat, jenkins, etc) working as apps I can tile (and remove decoration), that I can summon as an App or having them into my Menu.

You know, having something like that :wink: :

for now I’m using desktop file with chromium --app flag, but i’m think that there are all process related

Cheers Winael

1 Like