Snap remove fails because of user data

can’t remove snap when there is USER_DATA

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

Ubuntu core 18


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.

Can you tell us more?

Thanks for the reply

When removing the snap a second time, it was ok.

So here’s what I am doing:

sudo snap run --shell dkentry-python3.startup-dkentry

set | grep DATA



…some files…


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.