Remove hook not called

I built and installed my snap locally with an executable remove hook in the snap/hooks directory. Once built and installed (with the --dangerous flag) I checked if the remove shell script was included in the meta/hooks directory of the snap, it is.

When I remove this snap it does not seem to call the script. Any idea how to debug this?

The script is intended to crash (so I can check if it’s called):

set -e
exit 1

I tried another script writing to a file (and added the home plug to the snapcraft.yml file) but same result: nothing seems to happen. The snaps are build in a 16.04 cleanbuild LXD container.

My snap version:

snap    2.32.9+18.04
snapd   2.32.9+18.04
series  16
ubuntu  18.04
kernel  4.15.0-22-generic

What happens if you run snap run --hook remove <snap name> ?

That works as expected! The remove hook is executed. What does this mean?

After you snap remove the snap that has this remove hook, what’s the output of snap tasks --last=remove?

Thanks, it does work! The output of snap tasks --last=remove shows the error message:

ERROR ignoring failure in hook "remove": exit status 1

I expected the uninstall to fail when the remove hook crashes, just like the install hook but I now understand it simply silently fails. I was trying to use this to ask user confirmation before deleting the user’s data (a simple snap remove potentially trashes a ton of unrecoverable data) but the remove hook is probably no the way to do this.

Thanks all.