Snapcraft-runner not in classic snaps


When I build a snap with “confinement: strict” I get:
But when I build the same snap with “confinement: classic” this helper is not created.

This is a very handy script to have environment properly set, even though in classic mode.
Therefore, there is a way to force the automatic generation of this helper script while on classic mode?


The reason for this is that this script would leak into any shelled out command or library loaded from the classic system, with the potential of symbol conflicts generating core dumps. The use of environment variables on a classic confined snap should be carefully assessed by the snap publisher.

Thanks Sergio!, I understand the reason
I guessed it because environment is a tricky business.

But having a snapcraft-runner helper seemed to me a good starting point to order these things.
Because, conceptually a snap or an application should behave the same no matter if it is strict, classic or try (apart from the permissions) e.g. I have a snap that does not work in strict mode (because is not ready yet to do so) and it works with try (once variables set correctly) but it does not work with classic (I don’t know why yet but most likely it seems PATH or LD_LIBRARY_PATH related).

Because otherwise as you mentioned the responsibility is on the user, that’s ok mostly, but it is a problem (or time consuming) when you have to deal with inner variable dependencies like packages pulled from apt installed dependencies.

I know that this is not easy task, but you should work towards this scenario. At least for easy/most of the cases or having a more automated/predictable mechanism to control it.

Thanks again!

How are you launching the try’d snap? Working with try but failing when installed directly without try is not expected.

Hi Daniel,
Nothing special, I simply did

  • this runs as expected:
    sudo snapcraft try mysnap --classic
    sudo mysnap.start

  • and this fails at runtime:
    sudo snapcraft install mysnap.snap --classic --dangerous
    sudo mysnap.start

I wish to share more details about how it fails,
but currently I have no time to dig it deeply since try is enough for now.
Said that, I’ll try to solve the issue and give to you more details about what went wrong.
Or if you need something more specific tell me.

Other things that I tried are:

  • Create my snapcraft-runner like hook
    But it refuses to run (permissions error, but they are ok). So I forgot this idea quickly, as there are other ways to do it. Therefore I modified the starting scripts to set the variables at first (current situation).

  • Cheat snapcraft
    Indeed this worked very well. That’s why my original question about why snapcraft-runner could not be created by default or at least forced with a flag.
    Compile the snap as strict => it generates snapcraft-runner and its infrastructure
    Unpack and change strict to classic
    Repack and install or directly try

  • But going to the point again.

  1. Question: Is there a way to force snapcraft-runner in classic mode => no, and that it is ok
  2. Suggestion: All modes should behave similar except for the things that are explicitly different.

try and install behaves the same, after all it was my fault :sweat_smile:

  • To debug I did this change: @@ -1,4 +1,6 @@ -#!/bin/sh +#!/bin/bash +export PS4=’+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }’ +set -x

I did not realize that I changed also sh to bash to be able to do variable substitution And as a side effect I was solving other issue because our script does not work with dash (sh → dash)

Solved! And thanks for your help :smile:

1 Like