Cannot snap-exec: cannot exec "/snap/${PACKAGE_NAME}/${PACKAGE_REVISION}/snap/command-chain/snapcraft-runner": no such file or directory

Hi;

I’ve created and published an (edge) snap called “kycli”. Running it after doing a snap install kycli gives me the error specified in the title.

I’ve tried:

  1. Setting adapter: none and leaving it out.
  2. Overriding the standard golang plugin’s compilation process the way you see in its current source, so that it doesn’t require libc.
  3. Adding an organize: tag that moves it to “bin/” and then setting the command to “bin/kycli”. Also, setting the command, raw, to “kycli”.

Here is my current code:

name: kycli
summary: The command line interface to the unofficialkyc platform.
description: |
The command line interface to the unofficialkyc platform.
version: git
base: bare
build-base: core20
grade: devel
confinement: devmode
parts:
kycli:
    plugin: go
    source: .
    source-type: git
    build-packages: 
        - build-essential
        - musl
        - musl-dev
        - musl-tools
    override-build: |
        mkdir -p "${SNAPCRAFT_PART_INSTALL}"
        cd "${SNAPCRAFT_PART_SRC}"
        CC="$(which musl-gcc)" go build -ldflags '-linkmode external -extldflags "-static"' -o "${SNAPCRAFT_PART_INSTALL}" ./...
apps:
kycli:
    command: kycli
    adapter: none
    plugs:
        - network
        - browser-support

You can find the (currently in the process of being fixed) full set of application code here, which includes the above yml file. You can also download the app with the standard sudo snap install kycli --devmode --edge if you’d like.

I don’t really know how to introspect on the snapcraft-runner to see what exactly it’s trying to run, and where it’s looking, because the filesystem it’s located on is read only and it won’t let me modify the script ;p. I’ve tried running strace and ltrace too, but they didn’t really tell me much I could parse. I’m still not sure if it’s saying that it can’t run the kycli or if it genuinely doesn’t have it in its path — regardless, running it with /snap/8/kycli/bin/kycli works perfectly well.

my guess here would be that snapcraft-runner is a shell script but your snap uses base: bare which means a completely empty base snap that does not ship /bin/sh and as such wont be able to run the snapcraft-runner script (or any other script) that starts with #! /bin/sh

you could try to ship ash, dash, busybox or bash in your snap as a stage package (not sure, but i guess you’d also need to manually create the /bin/sh symlink here from your snapcraft.yaml part since snapcraft usually does not run update-alternatives to set it), but that will pull in dependencies and you will perhaps end up with having a bigger snap than using an existing base.

… or simply use a proper base (bare is just a experimental testbaloon AFAIK) like everyone else :slight_smile:

2 Likes

… or simply use a proper base (bare is just a experimental testbaloon AFAIK) like everyone else :slight_smile:

B-b-b-but I have to keep my package under 10MB!!!

I’ll check right now and see if I can fix the problem that way. Hopefully you’re right, although I think the snapcraft-runner runs on my host machine, no? It doesn’t shell into the VM and then run #!/bin/sh scripts to start my program, does it?

Can you verify that if you do something like:

apps:
  foo:
    command: foo
    adapter: none

that the resulting snap indeed does use command-chain? if so, that’d be a bug… and please dump the results of:

unsquashfs <snap>
cat squashfs-root/meta/snap.yaml

Also, logged a bug report for base: bare and command-chain. https://bugs.launchpad.net/snapcraft/+bug/1895140

1 Like

So, it turns out @ogra was correct. Adding busybox to my snap’s staged-packages: allows it to run. Seems a little weird that there’s a hidden dependency for bare snaps, given that my app most definitely does not require /bin/sh or /bin/bash. IMO it should be judiciously added to bare or the dependency should be removed.

@cjp256 The bug you made says that it should force adapter: none, but /bin/sh seems to be required regardless of the adapter setting. adapter: none is already present in the snapcraft file.

1 Like

FWIW, I built it myself (with the adapter: none) and no command chain was present. Maybe you installed the wrong snap build?

$ kycli 
Must specify a command.

    List of commands:
    register - Registers a new UFKYC passport.
    token - Grab a UFKYC token for the domain in your clipboard.
    donate [amount] - Donate to add to your credibility score (and buy some Kenyan kid a malaria net).
    service register - Registers a UFKYC service users will be able to generate.
    service register_domain [name] - Adds an (unvalidated) domain to your UFKYC service, and starts the validation process.
$ cat squashfs-root/meta/snap.yaml 
name: kycli
version: 0+git.7729357
summary: The command line interface to the unofficialkyc platform.
description: 'The command line interface to the unofficialkyc platform.

'
apps:
  kycli:
    command: kycli
    plugs:
    - network
    - browser-support
architectures:
- amd64
base: bare
confinement: devmode
grade: devel

@cjp256 Pretty sure that’s because I just uploaded the new version. Before I did, it wasn’t working.

@jdoe312

commit 7729357fae33534e070adc9c8dc48b7bdf9b6742 (HEAD -> master, origin/master, origin/HEAD)
Author: lc <dean@leonardcyber.com>
Date:   Thu Sep 10 06:49:33 2020 -0500

    Adding the (atm broken) snap + installation instructions.

@cjp256

Right, I haven’t committed the changes to the github repo, but I uploaded the new snapcraft app. I’m about to commit the snapcraft.yaml file now.

Perhaps I was a bit unclear. I built the snap myself from the ref 7729357fae33534e070adc9c8dc48b7bdf9b6742, installed it using --jailmode, and it appeared to work. I wanted to make sure that command-chain wasn’t getting generated with adapter: none (and it does not).

$ snapcraft
<snipped>
Staging kycli 
Priming kycli 
Determining the version from the project repo (version: git).
The version has been set to '0+git.7729357'
Snapping |                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Snapped kycli_0+git.7729357_amd64.snap

$ sudo snap install kycli_0+git.7729357_amd64.snap --jailmode --dangerous
kycli 0+git.7729357 installed

$ kycli 
Must specify a command.

    List of commands:
    register - Registers a new UFKYC passport.
    token - Grab a UFKYC token for the domain in your clipboard.
    donate [amount] - Donate to add to your credibility score (and buy some Kenyan kid a malaria net).
    service register - Registers a UFKYC service users will be able to generate.
    service register_domain [name] - Adds an (unvalidated) domain to your UFKYC service, and starts the validation process.

That’s… Strange. Wasn’t the behavior I was getting.