Error during scan: chmod(): Operation not permitted at /app/www/public/lib/private/Log/File.php#84

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 28.0.3
Operating system and version (eg, Ubuntu 20.04): Unraid OS 6.12.8
PHP version (eg, 7.4): 8.2

Docker container:
lscr.io/linuxserver/nextcloud

The issue you are facing:

root@3203889da4c3:/# occ files:scan --all
{“reqId”:“9DC2bJvA4n84CO4VVTyw”,“level”:1,“time”:“2024-03-06T15:21:28+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“admin_audit”,“method”:“”,“url”:“–”,“message”:“Console command executed: files:scan --all”,“userAgent”:“–”,“version”:“28.0.3.2”,“data”:{“app”:“admin_audit”}}
Starting scan for user 1 out of 5 (A_____)
Starting scan for user 2 out of 5 (E_____)
Exception during scan: File entry could not be inserted but could also not be selected with getId() in order to perform an update. Please try again.
#0 /app/www/public/lib/private/Files/Cache/Scanner.php(307): OC\Files\Cache\Cache->insert()
#1 /app/www/public/lib/private/Files/Cache/Scanner.php(240): OC\Files\Cache\Scanner->addToCache()
#2 /app/www/public/lib/private/Files/Cache/Scanner.php(480): OC\Files\Cache\Scanner->scanFile()
#3 /app/www/public/lib/private/Files/Cache/Scanner.php(404): OC\Files\Cache\Scanner->handleChildren()
#4 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#5 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#6 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#7 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#8 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#9 /app/www/public/lib/private/Files/Cache/Scanner.php(354): OC\Files\Cache\Scanner->scanChildren()
#10 /app/www/public/lib/private/Files/Utils/Scanner.php(277): OC\Files\Cache\Scanner->scan()
#11 /config/www/nextcloud/apps/files/lib/Command/Scan.php(180): OC\Files\Utils\Scanner->scan()
#12 /config/www/nextcloud/apps/files/lib/Command/Scan.php(241): OCA\Files\Command\Scan->scanFiles()
#13 /app/www/public/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute()
#14 /app/www/public/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run()
#15 /app/www/public/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run()
#16 /app/www/public/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#17 /app/www/public/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#18 /app/www/public/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run()
#19 /app/www/public/console.php(100): OC\Console\Application->run()
#20 /app/www/public/occ(11): require_once(‘…’)
#21 {main}
Starting scan for user 3 out of 5 (J_____)
Starting scan for user 4 out of 5 (K____)
Starting scan for user 5 out of 5 (M___)
Error during scan: chmod(): Operation not permitted
±--------±------±----±--------±--------±-------±-------------+
| Folders | Files | New | Updated | Removed | Errors | Elapsed time |
±--------±------±----±--------±--------±-------±-------------+
| 672 | 22196 | 0 | 5612 | 0 | 2 | 00:00:55 |
±--------±------±----±--------±--------±-------±-------------+
Error during scan: chmod(): Operation not permitted

Is this the first time you’ve seen this error? (Y/N):
Yes
Steps to replicate it:

  1. IDK

The output of your Nextcloud log in Admin > Logging:

{
  "reqId": "4tNAidWgylx8zoj1qIz7",
  "level": 3,
  "time": "2024-03-06T15:31:59+00:00",
  "remoteAddr": "aaa.bbb.ccc.ddd",
  "user": "A____",
  "app": "PHP",
  "method": "GET",
  "url": "/settings/admin/logging",
  "message": "chmod(): Operation not permitted at /app/www/public/lib/private/Log/File.php#84",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0.0",
  "version": "28.0.3.2",
  "data": {
    "app": "PHP"
  },
  "id": "65e88c7283da1"
}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '192.168.1.ddd',
    'port' => 6379,
    'password' => 'sensitive',
  ),
  'datadirectory' => '/data',
  'instanceid' => 'ocj49jkucnbm',
  'passwordsalt' => 'sensitive',
  'secret' => 'sensitive',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'cloud.sensitive.eu',
    2 => '192.168.1.ddd',
  ),
  'trusted_proxies' => 
  array (
    0 => '127.0.0.1',
    1 => '192.168.1.ddd',
  ),
  'dbtype' => 'pgsql',
  'version' => '28.0.3.2',
  'overwrite.cli.url' => 'https://cloud.sensitive.eu',
  'dbname' => 'cloud',
  'dbhost' => '192.168.1.ddd',
  'dbport' => '5432',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'sensitive',
  'dbpassword' => 'sensitive',
  'installed' => true,
  'integrity.check.disabled' => false,
  'mail_from_address' => 'sensitive',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'gmail.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'sensitive@gmail.com',
  'mail_smtppassword' => 'sensitive',
  'mail_smtpsecure' => 'ssl',
  'defaultapp' => 'files',
  'default_phone_region' => 'CZ',
  'updater.release.channel' => 'stable',
  'maintenance' => false,
  'loglevel' => 0,
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'twofactor_enforced' => 'false',
  'twofactor_enforced_groups' => 
  array (
    0 => 'admin',
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
  'theme' => '',
  'auth.bruteforce.protection.enabled' => false,
  'preview_max_memory' => '512',
  'preview_concurrency_all' => 16,
  'preview_concurrency_new' => 8,
  'enable_previews' => true,
  'preview_max_x' => 2048,
  'preview_max_y' => 2048,
  'enablePreviewProviders' => 
  array (
    0 => 'OC\\Preview\\Image',
    1 => 'OC\\Preview\\Movie',
    2 => 'OC\\Preview\\MKV',
    3 => 'OC\\Preview\\MP4',
    4 => 'OC\\Preview\\AVI',
    5 => 'OC\\Preview\\mov',
    6 => 'OC\\Preview\\PNG',
    7 => 'OC\\Preview\\JPEG',
    8 => 'OC\\Preview\\GIF',
    9 => 'OC\\Preview\\BMP',
    10 => 'OC\\Preview\\XBitmap',
    11 => 'OC\\Preview\\PDF',
    12 => 'OC\\Preview\\MP3',
    13 => 'OC\\Preview\\TXT',
    14 => 'OC\\Preview\\MarkDown',
    15 => 'OC\\Preview\\3GP',
    16 => 'OC\\Preview\\JPG',
  ),
  'filelocking.enabled' => 'true',
  'upgrade.disable-web' => 'true',
  'appstoreenabled' => 'true',
  'maintenance_window_start' => 1,
);

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

PASTE HERE

PASTE HERE


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.

(https://pastebin.com/fCPy1JkK)

Exception during scan: File entry could not be inserted but could also not be selected with getId() in order to perform an update. Please try again.

Anything recently change? This is essentially saying several impossible things are true simultaneously:

  • a new file as detected in the filesystem, but couldn’t be added to the filecache by the scanner (generally because it was added some other way in the mean time - which is fine)
  • the existing (just added presumably) filecache entry could not be found in the filecache when looking it up
  • since the entry can’t be added to the filecache nor looked up in it, Nextcloud gives up (because this indicates something is very wrong)

You might try running the scan with -vvv to see if you can isolate which file/folder belonging to E_____ is triggering this.

'logfile' => '/var/log/nextcloud/nextcloud.log',

The line this is generating the chmod() error suggests that the user that the web server is running as isn’t the owner /var/log/nextcloud/nextcloud.log. Did you by chance change the value of this parameter? Since you’re using a the LinuxServer Docker container, you likely want to log to /data/nextcloud.log (which would be the default if you don’t set the value). I don’t see this log entry (or anything from March in your posted pastebin log).

‘logfile’ => ‘/var/log/nextcloud/nextcloud.log’,

I used to add this line but I don’t know why, probably because of some application error. but I don’t remember. so I can try to delete it.

Here is the output from the console with the last 3 scanned files

input1: occ files:scan Eliska -vvv

output1
    File    /Eliska/files/Fotky/WhatsApp/WhatsApp Video/Sent/.nomedia
    File    /Eliska/files/Fotky/WhatsApp/WhatsApp Video/Sent/VID-20190629-WA0009.mp4
    File    /Eliska/files/Fotky/WhatsApp/WhatsApp Video/Sent/VID-20190629-WA0009.mp4

Exception during scan: File entry could not be inserted but could also not be selected with getId() in order to perform an update. Please try again.
#0 /app/www/public/lib/private/Files/Cache/Scanner.php(307): OC\Files\Cache\Cache->insert()
#1 /app/www/public/lib/private/Files/Cache/Scanner.php(240): OC\Files\Cache\Scanner->addToCache()
#2 /app/www/public/lib/private/Files/Cache/Scanner.php(480): OC\Files\Cache\Scanner->scanFile()
#3 /app/www/public/lib/private/Files/Cache/Scanner.php(404): OC\Files\Cache\Scanner->handleChildren()
#4 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#5 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#6 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#7 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#8 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#9 /app/www/public/lib/private/Files/Cache/Scanner.php(354): OC\Files\Cache\Scanner->scanChildren()
#10 /app/www/public/lib/private/Files/Utils/Scanner.php(277): OC\Files\Cache\Scanner->scan()
#11 /config/www/nextcloud/apps/files/lib/Command/Scan.php(180): OC\Files\Utils\Scanner->scan()
#12 /config/www/nextcloud/apps/files/lib/Command/Scan.php(241): OCA\Files\Command\Scan->scanFiles()
#13 /app/www/public/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute()
#14 /app/www/public/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run()
#15 /app/www/public/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run()
#16 /app/www/public/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#17 /app/www/public/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#18 /app/www/public/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run()
#19 /app/www/public/console.php(100): OC\Console\Application->run()
#20 /app/www/public/occ(11): require_once(‘…’)
#21 {main}

Error during scan: chmod(): Operation not permitted
#0 /config/www/nextcloud/apps/files/lib/Command/Scan.php(268): OCA\Files\Command\Scan->exceptionErrorHandler()
#1 [internal function]: OCA\Files\Command\Scan->OCA\Files\Command{closure}()
#2 /app/www/public/lib/private/Log/File.php(84): chmod()
#3 /app/www/public/lib/private/Log.php(403): OC\Log\File->write()
#4 /app/www/public/lib/private/Log.php(232): OC\Log->writeLog()
#5 /app/www/public/lib/private/Log.php(189): OC\Log->log()
#6 /app/www/public/lib/private/Log/PsrLoggerAdapter.php(192): OC\Log->info()
#7 /app/www/public/lib/private/AppFramework/ScopedPsrLogger.php(118): OC\Log\PsrLoggerAdapter->info()
#8 /config/www/nextcloud/apps/files/lib/Command/Scan.php(299): OC\AppFramework\ScopedPsrLogger->info()
#9 /config/www/nextcloud/apps/files/lib/Command/Scan.php(255): OCA\Files\Command\Scan->presentStats()
#10 /app/www/public/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute()
#11 /app/www/public/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run()
#12 /app/www/public/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run()
#13 /app/www/public/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#14 /app/www/public/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#15 /app/www/public/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run()
#16 /app/www/public/console.php(100): OC\Console\Application->run()
#17 /app/www/public/occ(11): require_once(‘…’)
#18 {main}
±--------±------±----±--------±--------±-------±-------------+
| Folders | Files | New | Updated | Removed | Errors | Elapsed time |
±--------±------±----±--------±--------±-------±-------------+
| 54 | 4285 | 0 | 2806 | 0 | 2 | 00:00:50 |
±--------±------±----±--------±--------±-------±-------------+
Error during scan: chmod(): Operation not permitted
#0 /config/www/nextcloud/apps/files/lib/Command/Scan.php(268): OCA\Files\Command\Scan->exceptionErrorHandler()
#1 [internal function]: OCA\Files\Command\Scan->OCA\Files\Command{closure}()
#2 /app/www/public/lib/private/Log/File.php(84): chmod()
#3 /app/www/public/lib/private/Log.php(403): OC\Log\File->write()
#4 /app/www/public/lib/private/Log.php(232): OC\Log->writeLog()
#5 /app/www/public/lib/private/Log.php(139): OC\Log->log()
#6 /app/www/public/lib/private/Log/PsrLoggerAdapter.php(110): OC\Log->critical()
#7 /app/www/public/lib/private/Log/ErrorHandler.php(58): OC\Log\PsrLoggerAdapter->critical()
#8 [internal function]: OC\Log\ErrorHandler->onShutdown()
#9 {main}
root@3203889da4c3:/#

Here is the output from the console with the last 3 scanned files with the line I deleted from config.conf.

‘logfile’ => ‘/var/log/nextcloud/nextcloud.log’,

input2: occ files:scan Eliska -vvv

output2
    File    /Eliska/files/Fotky/WhatsApp/WhatsApp Video/Sent/.nomedia
    File    /Eliska/files/Fotky/WhatsApp/WhatsApp Video/Sent/VID-20190629-WA0009.mp4
    File    /Eliska/files/Fotky/WhatsApp/WhatsApp Video/Sent/VID-20190629-WA0009.mp4

Exception during scan: File entry could not be inserted but could also not be selected with getId() in order to perform an update. Please try again.
#0 /app/www/public/lib/private/Files/Cache/Scanner.php(307): OC\Files\Cache\Cache->insert()
#1 /app/www/public/lib/private/Files/Cache/Scanner.php(240): OC\Files\Cache\Scanner->addToCache()
#2 /app/www/public/lib/private/Files/Cache/Scanner.php(480): OC\Files\Cache\Scanner->scanFile()
#3 /app/www/public/lib/private/Files/Cache/Scanner.php(404): OC\Files\Cache\Scanner->handleChildren()
#4 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#5 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#6 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#7 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#8 /app/www/public/lib/private/Files/Cache/Scanner.php(409): OC\Files\Cache\Scanner->scanChildren()
#9 /app/www/public/lib/private/Files/Cache/Scanner.php(354): OC\Files\Cache\Scanner->scanChildren()
#10 /app/www/public/lib/private/Files/Utils/Scanner.php(277): OC\Files\Cache\Scanner->scan()
#11 /config/www/nextcloud/apps/files/lib/Command/Scan.php(180): OC\Files\Utils\Scanner->scan()
#12 /config/www/nextcloud/apps/files/lib/Command/Scan.php(241): OCA\Files\Command\Scan->scanFiles()
#13 /app/www/public/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute()
#14 /app/www/public/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run()
#15 /app/www/public/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run()
#16 /app/www/public/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#17 /app/www/public/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#18 /app/www/public/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run()
#19 /app/www/public/console.php(100): OC\Console\Application->run()
#20 /app/www/public/occ(11): require_once(‘…’)
#21 {main}

Error during scan: chmod(): Operation not permitted
#0 /config/www/nextcloud/apps/files/lib/Command/Scan.php(268): OCA\Files\Command\Scan->exceptionErrorHandler()
#1 [internal function]: OCA\Files\Command\Scan->OCA\Files\Command{closure}()
#2 /app/www/public/lib/private/Log/File.php(84): chmod()
#3 /app/www/public/lib/private/Log.php(403): OC\Log\File->write()
#4 /app/www/public/lib/private/Log.php(232): OC\Log->writeLog()
#5 /app/www/public/lib/private/Log.php(189): OC\Log->log()
#6 /app/www/public/lib/private/Log/PsrLoggerAdapter.php(192): OC\Log->info()
#7 /app/www/public/lib/private/AppFramework/ScopedPsrLogger.php(118): OC\Log\PsrLoggerAdapter->info()
#8 /config/www/nextcloud/apps/files/lib/Command/Scan.php(299): OC\AppFramework\ScopedPsrLogger->info()
#9 /config/www/nextcloud/apps/files/lib/Command/Scan.php(255): OCA\Files\Command\Scan->presentStats()
#10 /app/www/public/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute()
#11 /app/www/public/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run()
#12 /app/www/public/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run()
#13 /app/www/public/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#14 /app/www/public/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#15 /app/www/public/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run()
#16 /app/www/public/console.php(100): OC\Console\Application->run()
#17 /app/www/public/occ(11): require_once(‘…’)
#18 {main}
±--------±------±----±--------±--------±-------±-------------+
| Folders | Files | New | Updated | Removed | Errors | Elapsed time |
±--------±------±----±--------±--------±-------±-------------+
| 54 | 4285 | 0 | 2806 | 0 | 2 | 00:00:19 |
±--------±------±----±--------±--------±-------±-------------+
Error during scan: chmod(): Operation not permitted
#0 /config/www/nextcloud/apps/files/lib/Command/Scan.php(268): OCA\Files\Command\Scan->exceptionErrorHandler()
#1 [internal function]: OCA\Files\Command\Scan->OCA\Files\Command{closure}()
#2 /app/www/public/lib/private/Log/File.php(84): chmod()
#3 /app/www/public/lib/private/Log.php(403): OC\Log\File->write()
#4 /app/www/public/lib/private/Log.php(232): OC\Log->writeLog()
#5 /app/www/public/lib/private/Log.php(139): OC\Log->log()
#6 /app/www/public/lib/private/Log/PsrLoggerAdapter.php(110): OC\Log->critical()
#7 /app/www/public/lib/private/Log/ErrorHandler.php(58): OC\Log\PsrLoggerAdapter->critical()
#8 [internal function]: OC\Log\ErrorHandler->onShutdown()
#9 {main}
root@3203889da4c3:/#

Otherwise, yes I made a lot of changes because the app started reporting errors. So I was changing permissions somewhere because my apps wouldn’t load to install, in the end it was the permissions of some files in /Nextcloud/data/appdata_ocj49jxxxxx . I would need something to fix the permissions throughout nextcloud.
Or reinstall the whole app but with that I need a way to transfer the users settings and their passwords so they don’t know.

Here’s the LOG as a file, it’s already quite large:

https://fileport.io/h7M1BxP4Xc8k

No one knows??
:disappointed_relieved: