Reccurring error from Cron - Call to a member function mkdir()

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): Nextcloud Hub 4 (26.0.0)
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04 on LXC in Proxmox Linux 5.15.85-1-pve x86_64
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.18.0
PHP version (eg, 7.4): 8.1.17

The issue you are facing:
Every 6 to 7 hours, the nextcloud cron job, which runs every 5 minutes, generate this error:

Subject: Cron www-data@Nextcloud php --define apc.enable_cli=1 -f /var/www/nextcloud/cron.php

Message:
Error: Call to a member function mkdir() on null in /var/www/nextcloud/lib/private/Files/SetupManager.php:265
Stack trace:
#0 /var/www/nextcloud/lib/private/Files/SetupManager.php(325): OC\Files\SetupManager->oneTimeUserSetup()
#1 /var/www/nextcloud/lib/private/Files/SetupManager.php(229): OC\Files\SetupManager->setupForUserWith()
#2 /var/www/nextcloud/lib/private/legacy/OC_Util.php(112): OC\Files\SetupManager->setupForUser()
#3 /var/www/nextcloud/lib/private/Files/Utils/Scanner.php(113): OC_Util::setupFS()
#4 /var/www/nextcloud/lib/private/Files/Utils/Scanner.php(155): OC\Files\Utils\Scanner->getMounts()
#5 /var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php(76): OC\Files\Utils\Scanner->backgroundScan()
#6 /var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php(113): OCA\Files\BackgroundJob\ScanFiles->runScanner()
#7 /var/www/nextcloud/lib/public/BackgroundJob/Job.php(78): OCA\Files\BackgroundJob\ScanFiles->run()
#8 /var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php(103): OCP\BackgroundJob\Job->start()
#9 /var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php(93): OCP\BackgroundJob\TimedJob->start()
#10 /var/www/nextcloud/cron.php(152): OCP\BackgroundJob\TimedJob->execute()
#11 {main}

My Nextcloud installation is just for family with very limited users (currently 2, including me) and I have not noticed any apparent issues from this.
However, it would be great if we could get this resolved and this error stop popping up.
Unfortunately, I am not able to say when it started, I had mis-configured the alerting and thus, was not receiving this, or any.

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. Let nextcloud brackground cron job work as per configuration recommendation
  2. Receive the error every 6 to 7 hours

The output of your Nextcloud log in Admin > Logging:

Error: Call to a member function mkdir() on null in /var/www/nextcloud/lib/private/Files/SetupManager.php:265
Stack trace:
#0 /var/www/nextcloud/lib/private/Files/SetupManager.php(325): OC\Files\SetupManager->oneTimeUserSetup()
#1 /var/www/nextcloud/lib/private/Files/SetupManager.php(229): OC\Files\SetupManager->setupForUserWith()
#2 /var/www/nextcloud/lib/private/legacy/OC_Util.php(112): OC\Files\SetupManager->setupForUser()
#3 /var/www/nextcloud/lib/private/Files/Utils/Scanner.php(113): OC_Util::setupFS()
#4 /var/www/nextcloud/lib/private/Files/Utils/Scanner.php(155): OC\Files\Utils\Scanner->getMounts()
#5 /var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php(76): OC\Files\Utils\Scanner->backgroundScan()
#6 /var/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php(113): OCA\Files\BackgroundJob\ScanFiles->runScanner()
#7 /var/www/nextcloud/lib/public/BackgroundJob/Job.php(78): OCA\Files\BackgroundJob\ScanFiles->run()
#8 /var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php(103): OCP\BackgroundJob\Job->start()
#9 /var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php(93): OCP\BackgroundJob\TimedJob->start()
#10 /var/www/nextcloud/cron.php(152): OCP\BackgroundJob\TimedJob->execute()
#11 {main}

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

<?php
$CONFIG = array (
'instanceid' => 'hidden',
'passwordsalt' => 'hidden',
'secret' => 'hidden',
'trusted_domains' =>
array (
0 => 'hidden',
),
'trusted_proxies' =>
array (
0 => 'hidden',
),
'datadirectory' => '/media/nextcloud/data',
'dbtype' => 'mysql',
'version' => '26.0.0.11',
'overwrite.cli.url' => 'hidden',
'dbname' => 'nextcloud',
'dbhost' => 'hidden',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'hidden',
'dbpassword' => 'hidden',
'installed' => true,
'defaultapp' => 'files',
'auth.bruteforce.protection.enabled' => true,
'forwarded_for_headers' =>
array (
0 => 'HTTP_X_FORWARDED',
1 => 'HTTP_FORWARDED_FOR',
),
'mail_domain' => 'hidden',
'mail_from_address' => 'nextcloud',
'mail_smtphost' => 'hidden',
'mail_smtpport' => 25,
'overwriteprotocol' => 'https',
'log_type' => 'syslog',
'logfile' => '',
'loglevel' => 0,
'logtimezone' => 'Pacific/Auckland',
'enable_previews' => true,
'enabledPreviewProviders' =>
array (
0 => 'OC\Preview\Image',
1 => 'OC\Preview\JPEG',
2 => 'OC\Preview\GIF',
3 => 'OC\Preview\PNG',
4 => 'OC\Preview\BMP',
5 => 'OC\Preview\XBitmap',
6 => 'OC\Preview\TIFF',
7 => 'OC\Preview\Movie',
8 => 'OC\\Preview\\HEIC',
9 => 'OC\\Preview\\AVI',
10 => 'OC\\Preview\\MP4',
11 => 'OC\\Preview\\MKV',

),
'preview_max_x' => '1024',
'preview_max_y' => '1024',
'jpeg_quality' => '60',
'preview_max_scale_factor' => 1,
'preview_max_memory' => 256,
'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' =>
array (
'host' => '/var/run/redis/redis-server.sock',
'port' => 0,
'timeout' => 1.5,
'password' => '',
'dbindex' => 0,
),
'ldapIgnoreNamingRules' => false,
'ldapProviderFactory' => 'OCA\User_LDAP\LDAPProviderFactory',
'maintenance' => false,
'theme' => '',
'trashbin_retention_obligation' => 'auto, 90',
'app_install_overwrite' =>
array (
0 => 'joplin',
1 => 'files_frommail',
2 => 'cookbook',
3 => 'printer',
4 => 'apporder',
5 => 'bruteforcesettings',
6 => 'epubreader',
7 => 'music',
8 => 'onlyoffice',
9 => 'qownnotesapi',
10 => 'collectives',
),
'appstoreenabled' => 'true',
'default_phone_region' => 'NZ',
'default_locale' => 'en_NZ',
'updater.release.channel' => 'stable',
'memories.exiftool' => '/var/www/nextcloud/apps/memories/exiftool-bin/exiftool-amd64-glibc',
'memories.ffmpeg_path' => '/usr/bin/ffmpeg',
'memories.ffprobe_path' => '/usr/bin/ffprobe',
'memories.transcoder' => '/var/www/nextcloud/apps/memories/exiftool-bin/go-vod-amd64',
'memories.no_transcode' => false,
'memories.qsv' => false,
);

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

no error in nginx error log (which is logical as this is run directly via PHP

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.

This log file does not exist on my setup