Hooks not found during 'try'

I’ve just added an install and configure hook to my snap.

This compiles fine but when I try to install from prime I’m getting an error suggesting that the hooks can’t be found.

The error

snap try --devmode prime
error: cannot perform the following tasks:
- Run configure hook of "pi-gation" snap if present (run hook "configure": cannot snap-exec: no such file or directory)

It doesn’t help that the error doesn’t print the path that it can’t find!

My snapcraft.yaml

apps:
  pi-gation:
    command: pi-gation-launch
    daemon: simple
    plugs: [network, network-bind]

hooks:
  install:
    plugs: []

  configure:
    plugs: []

Directory structure

snap
    - snapcraft.yaml
    - hooks
         install
         configure

are the files under hooks executable? If they are dynamic binaries, can their libraries be found in the snap? If they are interpreted, are the interpreters available?

So I found the problem.

My directory structure was:

- snap - hooks install configure

Which is all nice and correct, the problem was that I had been running ‘snapcraft’ from the ‘snap’ directory rather than the directory.

The doco appears to be silent on this point and snapcraft will happily run from the snap directory.
I’m thinking it would be usefully if snapcraft actually enforced running from the project directory rather than being clever, because in this case it certainly wasn’t.

Anyway after resetting all of my paths in snapcraft.yaml (as they are relative to where you run snapcraft rather than being relative to snapcraft.yaml - which is what I would have expected) my snap now works.

Thanks for the help.

Note:

I had a similar issue:

- Run post-refresh hook of "photoscape" snap if present (run hook "post-refresh": cannot snap-exec: no such file or directory)

My issue was that I put #!/usr/bin/bash on top of the hook file instead of #!/bin/bash.