How to use "command:"

Hello, I’m trying to create my first snap from the Hypnotix project just for playing with snapcraft, but I can’t understand how the “command:” parameter must be used.


parts: hypnotix-unofficial: # See ‘snapcraft plugins’ plugin: python source:

apps: hypnotix-unofficial: command: bin/hypnotix-unofficial plugs: [home, network, network-bind, removable-media]

returns: Failed to generate snap metadata: The specified command ‘bin/hypnotix-unofficial’ defined in the app ‘hypnotix-unofficial’ does not exist. Ensure that ‘bin/hypnotix-unofficial’ is installed with the correct path.

I read the documentation that says

Each key under apps is the command name that should be made available on users’ systems.

I thought “command:” is an “output” binary that I may name as I want, not an “input” command that should already exist on the system.

Can someone please help me to understand?

It isn’t an “output” binary, it is what to run when the command name is run.

It needs to match the content of the snap. The snap content comes from the parts: section.

Thanks for your reply, but you mean that “command:” is what to run AFTER the Snap is installed or when the snap is created?

I can’t understand why it says that The specified command ‘bin/hypnotix-unofficial’ defined in the app ‘hypnotix-unofficial’ does not exist.

In the docs they make an example creating

    command: bin/hello

so I guess that “hello” can be whatever I want, but creating the Snap it says that ‘hypnotix-unofficial’ doesn’t exists.

this is relative to the toplevel of your snap, so you are telling it that executing /snap/bin/hypnotix-unofficial (or simply hypnotix-unofficial when /snap/bin is in your path) will execute:


after switching into the confined namespace. you need to make sure it exists in this place when you make your command: point to it …

Hello, thanks for the explanation.

After many tests I understood that the command: path is the executing path of the standard application (not the snapped one). Eg. if the non-snapped application would run from /usr/bin/hypnotix the command: path should be /usr/bin/hypnotix. Can you please confirm?

Moreover I found that using /usr/bin/hypnotix - which is the right path for hypnotix binary - returns a “non exiting path” error… Looking from an online example I tried adding this stage part and it seems to work

- usr
- usr/bin

is this part necessary to use the path? It’s not written in the documentation I’m looking at (maybe it’s something which affects only me)

The snap still doesn’t run, but it’s a little step forward :slight_smile: Thanks

no, this is wrong, it is the path where your part: did put the executable inside the snap, this path is relative to the top level of your snap.

i.e. if your part: does something like:

    plugin: nil
      override-build: |
        cp mybinary $CRAFT_PART_INSTALL/my/shiny/bin/path/

your command: would then look like:

    command: my/shiny/bin/path/mybinary

and you would then be able to execute it as “mycommand” from /snap/bin after installation …

indeed, if the non-snapped app runs from /usr/bin/hypnotix and your part actually installed it in this path your command would then be usr/bin/hypnotix … but often building from source installs things into /usr/local/bin or somewhere else …

what helps here is to completely omit the apps block, build the snap. take a look inside the built snap where things ended up and only then create the apps block with the correct command: … one thing to not forget is that you should always omit the first slash and that everything is relative to the snaps top level.

1 Like

Thanks, it’s clear now.