Binary not found updating older snap (core18) - organize question

Hi there, I had an old snap that was built initially on core16. I am updating to core18 (for this snap).

Snippet:

 source: .
    override-build: |
      chmod +x prep/extractor.sh
      prep/extractor.sh
    organize:
      restic: bin/restic

Now after adding base: core18 and building, the error I get is:

Failed to generate snap metadata: The specified command 'bin/restic' defined in the app {'command': 'bin/restic'} does not exist.
Ensure that 'bin/restic' is installed with the correct path.

I have been reading the docs, and I cannot see any changes in the dump plugin and how organize is used… is there something special with snapcraft 3.x or core18 that changes the behaviour?

(Admittedly I am rusty on my snap building due to other priorities).

Hmm… what about if you build with the --debug flag and look for where the bin/img dir is found?

$ snapcraft --debug

This will drop you into a shell of the building snap when it fails so you can poke around. Might just be that your img dir is somewhere else.

Changes are a few and they were mentioned in the 3.0 release notes, to not burden you with them, how about you point me to your repo and I propose a fix with comments on why things changed?

@sergiusensThank you for having a look.

I know this is an odd snap that just stuffs a go binary in but it was the authors preference to keep his compiled binary.

When I had done this prior, I only found folders with the proper name - no binaries. (which backups the error).

(Ran from within the debug vm)

$ find / -iname restic
/root/parts/restic
/root/parts/restic/build/restic

Thank you.

Here is a PR with comments in YAML and commit

https://github.com/bashfulrobot/snapcrafters-restic/pull/2

I believe the reason it was not working for you is that your script was downloading the wrong thing and given that the script was not set to fail on errors, everything finished correctly for which, at the point snapcraft tried to organize, it could not find anything.

FWIW, there is no need to put things in the bin directory, this is a single binary application so it might as well live in the root of the snap (you can of course change that from the PR).

Cheers,
Sergio

1 Like

I just saw the PR and merged it - I appreciate your help! You essentially plopped the solution right into my lap. It was very helpful to see how someone else would build out the same snap and what you did differently (beyond the actual resolution).

Now as to why the script would download the wrong thing - that is confusing. Because prior to updating to core18 and moving from prepare to build-override - that exact script has been working (and still does if I revert to the old YAML file) for quite some time.

But with that being said -everything builds great now.

Thank you again!

You are indeed correct. I took a closer look and the override-build seemed to not have performed the installation (organize works from the install directory)

1 Like

Just out of curiosity if I had to use organize - it would work after using the install command?

You organize is correct and you could bring it back as is if you really wanted that bin directory, but considering you are already scripting, it might just be easier to

install -D restic_0.9.6_linux_$SNAP_ARCH $SNAPCRAFT_PART_INSTALL/bin/restic

organize is useful and was first introduced when there was no possibility for scripting as we thought we could build something entirely declarative, turns out everyone likes doing things differently :wink:

1 Like