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):
#!/bin/sh
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
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.