Error deleting folders (or moving folders)

Nextcloud version: 26.0.2
Operating system and version: Linux 6.1.21-v8+ aarch64
Apache or nginx version: nginx/1.18.0
PHP version : 8.1.19

The issue you are facing:
Cannot delete folders.

Is this the first time you’ve seen this error?: Y; this was working fine with NC 26.0.1

Steps to replicate it:

  1. Create a folder
  2. Try to delete it (fails).
  3. Try to move it (fails)

Folder deletion fails in both my ‘admin’ account and my ‘user’ account.

The output of your Nextcloud log in Admin > Logging:

Error	webdav	TypeError: OC\Files\Cache\QuerySearchHelper::getCachesAndMountPointsForSearch(): Argument #1 ($root) must be of type OC\Files\Node\Root, OC\Files\Node\LazyRoot given, called in /config/www/nextcloud/lib/private/Files/Node/Folder.php on line 237

Line 237 of Folder.php mentioned above is shown below in context:

 216         /**
    217          * search for files with the name matching $query
    218          *
    219          * @param string|ISearchQuery $query
    220          * @return \OC\Files\Node\Node[]
    221          */
    222         public function search($query) {
    223                 if (is_string($query)) {
    224                         $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', '%' . $query . '%'));
    225                 }
    227                 // search is handled by a single query covering all caches that this folder contains
    228                 // this is done by collect
    230                 $limitToHome = $query->limitToHome();
    231                 if ($limitToHome && count(explode('/', $this->path)) !== 3) {
    232                         throw new \InvalidArgumentException('searching by owner is only allows on the users home folder');
    233                 }
    235                 /** @var QuerySearchHelper $searchHelper */
    236                 $searchHelper = \OC::$server->get(QuerySearchHelper::class);
    237                 [$caches, $mountByMountPoint] = $searchHelper->getCachesAndMountPointsForSearch($this->root, $this->path, $limitToHome);
    238                 $resultsPerCache = $searchHelper->searchInCaches($query, $caches);
    240                 // loop through all results per-cache, constructing the FileInfo object from the CacheEntry and merge them all
    241                 $files = array_merge(...array_map(function (array $results, string $relativeMountPoint) use ($mountByMountPoint) {
    242                         $mount = $mountByMountPoint[$relativeMountPoint];
    243                         return array_map(function (ICacheEntry $result) use ($relativeMountPoint, $mount) {
    244                                 return $this->cacheEntryToFileInfo($mount, $relativeMountPoint, $result);
    245                         }, $results);
    246                 }, array_values($resultsPerCache), array_keys($resultsPerCache)));
    248                 // don't include this folder in the results
    249                 $files = array_filter($files, function (FileInfo $file) {
    250                         return $file->getPath() !== $this->getPath();
    251                 });
    253                 // since results were returned per-cache, they are no longer fully sorted
    254                 $order = $query->getOrder();
    255                 if ($order) {
    256                         usort($files, function (FileInfo $a, FileInfo $b) use ($order) {
    257                                 foreach ($order as $orderField) {
    258                                         $cmp = $orderField->sortFileInfo($a, $b);
    259                                         if ($cmp !== 0) {
    260                                                 return $cmp;
    261                                         }
    262                                 }
    263                                 return 0;
    264                         });
    265                 }
    267                 return array_map(function (FileInfo $file) {
    268                         return $this->createNode($file->getPath(), $file);
    269                 }, $files);
    270         }

The output of your config.php file:

$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'datadirectory' => '/data',
  'trusted_proxies' =>
  array (
    0 => 'swag',
  'overwritewebroot' => '/nextcloud',
  'overwrite.cli.url' => 'https://xxxx/nextcloud',
  'trusted_domains' =>
  array (
    0 => 'xxxx',
    1 => 'localhost',
    2 => '',
  'instanceid' => 'ocmke58vu0cb',
  'passwordsalt' => 'rYdWyq8CoYUcorAKjPqt161XkddHir',
  'secret' => '4RbRv5fjXiGTHBGeDUxy3X9J5YcVxO369CzpbZ4whRH3J7x5',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextclouddb',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_admin',
  'dbpassword' => '[9G86rR]7PuU<erbb503tZ*B8+*U&3',
  'installed' => true,
  'memories.exiftool' => '/config/www/nextcloud/apps/memories/exiftool-bin/exiftool-aarch64-musl',
  'memories.vod.path' => '/config/www/nextcloud/apps/memories/exiftool-bin/go-vod-aarch64',
  'memories.vod.ffmpeg' => '/usr/bin/ffmpeg',
  'memories.vod.ffprobe' => '/usr/bin/ffprobe',
  'updater.secret' => '$2y$10$eEIXuk1jEyuhHHCg5B.1Be8qpnNeWeduV1LR0sL76Fzz/KOUOm8Tu',
  'mail_from_address' => 'x',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'xxxx',
  'mail_smtpsecure' => 'ssl',
  'mail_smtphost' => '',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'xxxxx',
  'mail_smtppassword' => 'xxxxx',
  'default_phone_region' => 'CA',
  'maintenance' => false,
  'loglevel' => 2,

The output of your Apache/nginx/system log in /var/log/____:

(not sure where to find this):
find . -type f -name "system.log"
find: ‘./lost+found’: Permission denied
find: ‘./docker’: Permission denied
find: ‘./appdata/nextclouddb/databases/performance_schema’: Permission denied
find: ‘./appdata/nextclouddb/databases/mysql’: Permission denied
find: ‘./appdata/nextclouddb/databases/sys’: Permission denied
find: ‘./appdata/nextclouddb/databases/nextcloud’: Permission denied
find: ‘./appdata/swag/etc/letsencrypt/archive’: Permission denied
find: ‘./appdata/swag/etc/letsencrypt/live’: Permission denied
find: ‘./appdata/swag/etc/letsencrypt/accounts’: Permission denied

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{"reqId":"ILkxADsYLFau4URcQRmG","level":3,"time":"2023-05-15T21:55:01+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"/nextcloud/cron.php","message":"Not installed","userAgent":"--","version":"","exception":{"Exception":"Exception","Message":"Not installed","Code":0,"Trace":[{"file":"/config/www/nextcloud/lib/base.php","line":697,"function":"checkInstalled","class":"OC","type":"::"},{"file":"/config/www/nextcloud/lib/base.php","line":1165,"function":"init","class":"OC","type":"::"},{"file":"/config/www/nextcloud/cron.php","line":43,"args":["/config/www/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/config/www/nextcloud/lib/base.php","Line":281,"CustomMessage":"--"}}
{"reqId":"a6HXQM25qqx4oTFT2Tbs","level":3,"time":"2023-05-15T22:00:01+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"/nextcloud/cron.php","message":"Not installed","userAgent":"--","version":"","exception":{"Exception":"Exception","Message":"Not installed","Code":0,"Trace":[{"file":"/config/www/nextcloud/lib/base.php","line":697,"function":"checkInstalled","class":"OC","type":"::"},{"file":"/config/www/nextcloud/lib/base.php","line":1165,"function":"init","class":"OC","type":"::"},{"file":"/config/www/nextcloud/cron.php","line":43,"args":["/config/www/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/config/www/nextcloud/lib/base.php","Line":281,"CustomMessage":"--"}}
{"reqId":"DELRi8b2f4wuezvad93t","level":2,"time":"2023-05-16T12:35:47+00:00","remoteAddr":"","user":"--","app":"core","method":"PROPFIND","url":"/nextcloud/remote.php/dav/files/Ray/","message":"Login failed: 'Ray' (Remote IP: '')","userAgent":"Mozilla/5.0 (Windows) mirall/3.8.1stable-Win64 (build 20230419) (Nextcloud, windows-10.0.22621 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"","data":{"app":"core"}}
{"reqId":"TigB4GpIcB17njqC3Jpd","level":2,"time":"2023-05-16T12:35:47+00:00","remoteAddr":"","user":"--","app":"core","method":"PROPFIND","url":"/nextcloud/remote.php/dav/files/Ray/","message":"Login failed: 'Ray' (Remote IP: '')","userAgent":"Mozilla/5.0 (Windows) mirall/3.8.1stable-Win64 (build 20230419) (Nextcloud, windows-10.0.22621 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"","data":{"app":"core"}}

Any help appreciated,


From Fix file delete, moved and copy, I disable the Music App (v1.8.3) and can now delete folders. Hopefully the good folks at NC (or the app developer) can fix this as I use the Music app a lot.


Although this happens on the callback of the Music app, I believe that the root cause is a bug in Nextcloud.

As a quick-and-dirty monkey patch, you may modify the file lib/private/Files/Cache/QuerySearchHelper.php in your installation. Locate the line
public function getCachesAndMountPointsForSearch(Root $root, string $path, bool $limitToHome = false): array {
and modify it to be
public function getCachesAndMountPointsForSearch($root, string $path, bool $limitToHome = false): array {
i.e. remove the type declaration Root.


Thanks for the insight. I just ran into the same problem.

Same here. Disabling the Music App solved the problem.

Isn’t music supported?

1 Like

There is already a fix waiting to be merged: fix: expect interface, not a specific implementation by blizzz · Pull Request #38625 · nextcloud/server · GitHub.
So most likely, everything will work again in the next releases of Nextcloud (25.0.8, 26.0.3, 27.0.0). Until then, you may apply the manual fix suggested above.


Disabling Music 1.8.3 on Nextcloud works for me as well.
Looking forward to the above fix being merged.

Thanks all for your contributions! This helped me a lot understanding the issue and finding a workaround. I thought I had screwed up something with my Nextcloud installation …

Same issue. Disabling music also fixed it for me.

Thank you,
Wolf Larson

TYVM! Been trying to get this one working for weeks. Same issue.
Confirmed working after disabling music.

disabling the music app also works for me - waiting for bugfix :slight_smile:

Same for me, the music app hock is the issue.
It also created the side effect for other files and folders to be doubled, moved, or even deleted when re-organizing a folder structure

The fix for this is now on track to be included in Nextcloud releases 27.0.1 and 26.0.4. It should be included also in 25.0.9 but that will still require some manual work. All of these versions are supposed to be released on 2023-07-20.

Until then, implementing the work around I suggested above in Error deleting folders (or moving folders) - #3 by paulijar should be quite easy.

1 Like

I can confirm 27.0.1 fixed it. Docker

Music plugin works and I can delete folders properly.

The fix for this was released a few days ago in the Nextcloud versions 25.0.9, 26.0.4, and 27.0.1.