Unable to update apps on Nextcloud16

Nextcloud 16.0.1recently upgraded step by step from ownCloud 10
Ubuntu 18.04

I am not able to update any apps that give notice that there is a new version available. The log shows error messages for every file in the app that I attempt to update. Two messages are repeatly logged, sample shown:

Error PHP rmdir(/var/www/nextcloud/apps/richdocuments/templates): Directory not empty at /var/www/nextcloud/lib/private/legacy/helper.php#171
Error PHP unlink(/var/www/nextcloud/apps/richdocuments/templates/documents.php): Permission denied at /var/www/nextcloud/lib/private/legacy/helper.php#173

I tried changing permissions on the Nextcloud and data directories to the ones in the Nextcloud 15 or older manuals but that resulted in the plugins disappearing all together. Nextcloud 16 permissions were changed. The plugins reappeared when I changed back to the permissions used by the installer.

I found I could update Contacts and Notes by disabling the apps, clicking remove and then manually removing their directories from the /nextcloud/apps directory. But this did not work for apps (Collabora, Talk, Clamav) that have configuration settings under Settings> Admin.

I have not seen this issue on fresh installs of Nextcloud that I have done for testing and 2 other installations. In the migration from ownCloud I did have a problem at one step with plugins showing but was able to make it work after some research, I think that was at Nextcloud 12 to 13 or 11 to 12.

It did eventually work to delete the app directories of the affected apps. Not sure why. But I am now able to update apps normally and some have now gone 2 rounds without the problem reoccurring.