App description field 'command' contains illegal

Hi all,

i try to build a snap for my Glances project (see the issue here: https://github.com/nicolargo/glances/issues/1801).

The build failed with the following error:

stderr:
error: cannot pack "/build/glances/prime": cannot validate snap "glances": invalid definition of application "glances": app description field 'command' contains illegal "bin/glances-launch $SNAP/bin/glances\n" (legal: '^[A-Za-z0-9/. _#:$-]*

My snapcraf.yml file is the following:

name: glances
adopt-info: glances
summary: Glances an Eye on your system. A top/htop alternative.
description: |
  Glances is a cross-platform monitoring tool which aims to present
  a maximum of information in a minimum of space through a curses or
  Web based interface. It can adapt dynamically the displayed information
  depending on the user interface size.

base: core20
grade: stable
confinement: strict

apps:
  glances:
    command: >
      bin/glances-launch
      $SNAP/bin/glances
    plugs:
      - network
      - system-observe
      - mount-observe
      - hardware-observe
      - log-observe
      - network-observe
      - physical-memory-observe
      - upower-observe
      - home
      - network-bind
    environment:
      LANG: C.UTF-8
      LC_ALL: C.UTF-8

plugs:
  home-glances-config:
    interface: personal-files
    read:
      - $HOME/.config/glances/glances.conf
  etc-glances-config:
    interface: system-files
    read:
      - /etc/glances/glances.conf

parts:
  glances:
    after:
    - selective-checkout
    plugin: python
    source: .
    # FIXME: Theoretically this also replaces `summary` and `description`
    #        keys, however due to the following bug we still need to keep
    #        them until it is fixed.
    #        https://bugs.launchpad.net/snapcraft/+bug/1813364
    parse-info: [setup.py]
    override-pull: |
      snapcraftctl pull
      "$SNAPCRAFT_STAGE"/scriptlets/selective-checkout
  bottle:
    plugin: python
    source: https://github.com/bottlepy/bottle.git
    source-branch: release-0.12
    source-depth: 1
    override-build: |
      mkdir -p $SNAPCRAFT_PART_BUILD/dist
      cp -r $SNAPCRAFT_PART_BUILD/dist $SNAPCRAFT_PART_INSTALL/bottle-dist
    organize:
      bottle-dist: bottle/dist
  docker:
    plugin: python
    source: https://github.com/docker/docker-py.git
    source-tag: '3.7.3'
    source-depth: 1
    override-build: |
      mkdir -p $SNAPCRAFT_PART_BUILD/dist
      cp -r $SNAPCRAFT_PART_BUILD/dist $SNAPCRAFT_PART_INSTALL/docker-dist
    organize:
      bottle-dist: docker/dist
  launchers:
    source: snap/local/launchers
    plugin: dump
    organize:
      '*': bin/
  selective-checkout:
    plugin: nil
    build-packages:
    - git
    stage-snaps:
    - selective-checkout
    prime:
    - -*

Any idea to solve my issue ?

Thanks !

    command: >
      bin/glances-launch
      $SNAP/bin/glances

I’m confused how to interpret this, it seems like you want to run two commands one after the other?

if they were on the same line, snapcraft wouldn’t complain and at runtime, $SNAP/bin/glances would be passed as a parameter to bin/glances-launch, this would make sense if bin/glances-launch had something equivilent to exec $@ at the end, which is how the desktop-launch scripts work.

If you do not want them to be passed as parameters and simply want one to run after the other, you likely need to change bin/glances-launch to compensate for this, having it launch $SNAP/bin/glances itself.

You likely want either of the following:

    command: >-
      bin/glances-launch
      $SNAP/bin/glances

or

    command: bin/glances-launch $SNAP/bin/glances

Alternatively you could use command-chain:

    command-chain:
      - bin/glances-launch
    command: bin/glances
3 Likes