Cannot delete directory error thrown by updater when upgrading 30.0.11 to 31.0.5

I tried to upgrade my nextcloud version 30.0.11 to 31.0.5 . I ran the upgrade via:

sudo -u www-data php /var/www/owncloud/updater/updater.phar --no-backup

Finally the upgrade fails with an error when trying to delete a directory:
/var/www/owncloud/data/updater-octpturgf05m/downloads/nextcloud/apps/settings

When I rerun the upgrade the story remains the same but wit a different directory that failed to delete. And when I try to delete the directory that the updater could not delete by using sudo -u www-data rmdir <directorypath> this works just fine . I also checked that all files in the upgrader directory belong to the apache user which is www-data on my ubuntu 24.04 system. For now I can return back to 30.0.11 because the cloud is running in a virtual machine that I snapshotted before upgrading, so I can start again from a running 30.0.11 system.

Rerunning updater.phar after it failed one time it fails again in the next run in the same step but for another directory. I tried 3 times and got each time an error for a different upgrader dir in each try:

 Could not rmdir /var/www/owncloud/data/updater-octpturgf05m/downloads/nextcloud/apps/settings
 Cloud not rmdir /var/www/owncloud/data/updater-octpturgf05m/downloads/nextcloud/apps/user_ldap/lib/Notification
 Could not rmdir /var/www/owncloud/data/updater-octpturgf05m/downloads/nextcloud/apps/files_versions/lib/Migration

The given directotry was always empty and could easily be remove by running

sudo -u www-data rmdir <path>

I also checked that there is enough free space on the filesystem.
Its really strange this error, no idea whats going on.

The following log is from /var/log/owncloud and shows the relevant part where the upgrader fails in one run:

2025-05-31T04:17:14+0000 6eSrdSe8D9 [info] storage location: /var/www/owncloud/data/updater-octpturgf05m/downloads/
2025-05-31T04:17:29+0000 6eSrdSe8D9 [info] end of verifyIntegrity()
2025-05-31T04:17:29+0000 6eSrdSe8D9 [info] endStep("5")
2025-05-31T04:17:29+0000 6eSrdSe8D9 [info] executeStep request for step "6"
2025-05-31T04:17:29+0000 6eSrdSe8D9 [info] startStep("6")
2025-05-31T04:17:29+0000 6eSrdSe8D9 [info] extractDownload()
2025-05-31T04:17:29+0000 6eSrdSe8D9 [info] storage location: /var/www/owncloud/data/updater-octpturgf05m/downloads/
2025-05-31T04:17:29+0000 6eSrdSe8D9 [info] Libzip version detected: 1.7.3
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] end of extractDownload()
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] endStep("6")
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] executeStep request for step "7"
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] startStep("7")
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] setMaintenanceMode("true")
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] configFileName /var/www/owncloud/updater/../config/config.php
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] end of setMaintenanceMode()
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] endStep("7")
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] executeStep request for step "8"
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] startStep("8")
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] replaceEntryPoints()
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] replace index.php
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] replace status.php
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] replace remote.php
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] replace public.php
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] replace ocs/v1.php
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] replace ocs/v2.php
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] end of replaceEntryPoints()
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] endStep("8")
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] executeStep request for step "9"
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] startStep("9")
2025-05-31T04:24:46+0000 6eSrdSe8D9 [info] deleteOldFiles()
2025-05-31T04:24:53+0000 6eSrdSe8D9 [info] config sample exists
2025-05-31T04:24:53+0000 6eSrdSe8D9 [info] themes README exists
2025-05-31T04:57:37+0000 6eSrdSe8D9 [info] end of deleteOldFiles()
2025-05-31T04:57:37+0000 6eSrdSe8D9 [info] endStep("9")
2025-05-31T04:57:37+0000 6eSrdSe8D9 [info] executeStep request for step "10"
2025-05-31T04:57:37+0000 6eSrdSe8D9 [info] startStep("10")
2025-05-31T04:57:38+0000 6eSrdSe8D9 [info] moveNewVersionInPlace()
2025-05-31T04:57:38+0000 6eSrdSe8D9 [info] storage location: /var/www/owncloud/data/updater-octpturgf05m/downloads/nextcloud/
2025-05-31T05:01:30+0000 6eSrdSe8D9 [error] executeStep request failed with other exception
2025-05-31T05:01:30+0000 6eSrdSe8D9 [error] Exception: Exception
Message: Could not rmdir /var/www/owncloud/data/updater-octpturgf05m/downloads/nextcloud/apps/settings
Code:0
Trace:
#0 phar:///var/www/owncloud/updater/updater.phar/lib/Updater.php(1012): NC\Updater\Updater->moveWithExclusions()
#1 phar:///var/www/owncloud/updater/updater.phar/lib/UpdateCommand.php(399): NC\Updater\Updater->moveNewVersionInPlace()
#2 phar:///var/www/owncloud/updater/updater.phar/lib/UpdateCommand.php(240): NC\Updater\UpdateCommand->executeStep()
#3 phar:///var/www/owncloud/updater/updater.phar/vendor/symfony/console/Command/Command.php(298): NC\Updater\UpdateCommand->execute()
#4 phar:///var/www/owncloud/updater/updater.phar/vendor/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run()
#5 phar:///var/www/owncloud/updater/updater.phar/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#6 phar:///var/www/owncloud/updater/updater.phar/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#7 phar:///var/www/owncloud/updater/updater.phar/updater.php(12): Symfony\Component\Console\Application->run()
#8 /var/www/owncloud/updater/updater.phar(14): require('...')
#9 {main}
File:phar:///var/www/owncloud/updater/updater.phar/lib/Updater.php

Please note the base-directory is named owncloud, however the running software is really a nextcloud.

I had another idea but it didn’t proove true: on my Nextcloud-VM AppAmor was activated. Thought this could possibly prevent the system from removing directories. However after disabling AppAmor (Kernel-Module as well as the AppArmor service and a reboot), nothing changed when upgrading. Again I got the “cannot remove directory” error message during the “Move new files in place” step during the upgrade.

In between I was able to upgrade one version but my basic problem is still there. So I want to give some more detail perhaps this help to find a solution:

I use updater.phar , also tried the built-in graphical updater to upgrade, no difference.
The problem I have is that each upgrade process throws an error in the state Move new files in place. The error says that the updater was unable to rmdir a directory eg

/var/www/owncloud/data/updater-octpturgf05m/downloads/nextcloud/lib/private/Avatar

Sometimes the error complains about another directory below .../updater-octpturgf05m/ but in most cases its alwyas the same directory .
However when I look at the directory and its parent the permission are 775 for both directory and parent dir and the directory and its parent belongs to www-data:www-data and running sudo -u www-data rmdir <path> simply works without any problems.
I managed to get to 30.0.12 by using kind of “hack”. When the update was running in state “Deleting old files” I manually ran a find . -type d |xargs chmod go+rxw on the updaters directory.

/var/www/owncloud/data/updater-octpturgf05m/downloads/nextcloud/lib/private/Avatar

So all directories are then 777. This worked to go to 30.0.12 but when I tried to do the same to get to 31.0.6 the trick did not work any longer. Again there was a folder for which the updater said it could not be deleted

My nextcloud is installed on a Ubuntu 24.05 system. Its running as virtual machine on a TS-251 QNAP NAS system, so its not really the fastest cloud, but always did its job very well.

Any ideas what might cause this problems are welcome…

Thank you very much Rainer

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.