The problem here, at least on Raspberry pi systems running Debian, is that sudo does not pick up on paths exported from your user profile. See here for details.
The solution is to add /snap/bin to the list of paths that sudo recognises –
sudo visudo
and then add
/snap/bin/
to the line that starts
secure_paths
in that file. After that, snaps will run with sudo and without errors. Otherwise, commands like
sudo /snap/bin/nextcloud.occ
will work, but why type the extra?