Configure hook doesn't run

Have I missed something here?

There is supposedly a configure hook for snap set

I write my own it doesn’t work, I run the hooks demo in

this also doesn’t work:

bugg@tom-laptop2:~/Projects/snapcraft/demos/hooks/snap$ sudo snap set hooks fail=true

error: cannot perform the following tasks:

  • Run configure hook of “hooks” snap (snap “hooks” has no “configure” hook)

Do they not work or am I doing something wrong?

bugg@tom-laptop2:~/Projects/snapcraft/demos/hooks/snap$ snap --version
snap    2.26.9
snapd   2.26.9
series  16
ubuntu  16.04
kernel  4.4.0-83-generic


Hmm… that demo is run in CI, and works locally for me with the same versions. Not sure what’s happening. Did you actually clone the demo? If you just duplicated it, make sure the hook is executable.

Sorry yeah my fault on the demo it does run.

My own doesn’t still, if you get 2 minutes can you peruse my code and see if its obvious?

Okay so I have it working but someone needs to explain this to me a bit, or possibly in the docs because I’m fully confused.

I have a project with files, if I do


from within that folder the hooks don’t get built and it doesn’t work.

If I have


and then run snapcraft frorm the openldap folder which is empty except the snap subfolder it appears my hooks get generated.

Why does the location of the snapcraft file make a difference?

I’m not completely clear on what you’re saying, but looking at the history of your project I think I understand. To clarify, you’re saying:

Structuring my project like this doesn’t work:

|- snapcraft.yaml
|- hooks/
   |- configure

But structuring it like this does:

|- snap/
   |- snapcraft.yaml
   |- hooks/
      |- configure

Assuming I understand correctly, it has less to do with the location of the snapcraft.yaml and more to do with the location of the hooks themselves.

Referring to the docs, there are two ways to tell snapcraft to put hooks into your snap:

  1. Putting them in <root>/snap/hooks/
  2. Build your hooks as parts and install them into <snap>/snap/hooks/

It appears you’re trying to do (1), but you didn’t follow that directory layout in the first rendition. Only in the second did you conform to the necessary convention.