snap remove dkentry-python3
error: cannot perform the following tasks:
Remove data for snap “dkentry-python3” (x1) (failed to remove snap “dkentry-python3” base directory: remove /var/snap/dkentry-python3: directory not empty)
? is there a way to keep the user data and still remove the snap
There’s some confusion in your question, which I’ll try to untangle, but there’s also the strangeness that what you’re reporting doesn’t make sense in view of how things work, so there’s something non-obvious going on.
Let’s see: /var/snap/<snap>/ is not “USER_DATA”, it’s the parent directory of both $SNAP_COMMON and $SNAP_DATA. $SNAP_USER_DATA is typically /home/<user>/snap/<snap>/<revision>.
Snaps with data in any of these directories can be removed perfectly fine. The contents of those directories are backed up before the directories are removed (the --purge option to snap remove skips the backup).
So there’s something more going on: something you or your snap has done that the system can’t remove.
sudo snap run --shell dkentry-python3.startup-dkentry
set | grep DATA
SNAP_DATA=/var/snap/dkentry-python3/x1
SNAP_USER_DATA=/root/snap/dkentry-python3/x1
#ls $SNAP_DATA
…some files…
exit
snap remove dkentry-python3
dkentry-python3 removed
? if the snap is running as sudo, should the apps use SNAP_DATA or SNAP_USER_DATA
The apps need an area to r/w data, but access to other snaps is not needed.