Nextcloud 29.0.0 Cannot write into "config" directory

Nextcloud version (eg, 20.0.5): 29.0.0 (LSIO docker container)
Operating system and version (eg, Ubuntu 20.04): Unraid 6.12.10
Apache or nginx version (eg, Apache 2.4.25): 1.24.0 (LSIO SWAG container)
PHP version (eg, 7.4): 8.3.7

The issue you are facing:
In Security and Setup Warnings, I see the following:
The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster. Missing optional index “oc_npushhash_di” in table “notifications_pushhash”.

I have had this before (I’ve been using Nextcloud for many years so no particular recollection of when or what version) so I open a terminal inside the docker container and run the following command: sudo -u abc php /app/www/src/occ db:add-missing-indices. When I run said command, I receive the following:

Cannot write into "config" directory!
This can usually be fixed by giving the web server write access to the config directory.

But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.
See https://docs.nextcloud.com/server/29/go.php?to=admin-config

I have never received this command previously when running the add-missing-indices command. I have checked ownership and permissions on the config folder:

root@f35d883492e5:/# ls -alh /config/www/nextcloud/
total 21K
drwxr-x---  5 abc abc  5 Jun 27  2023 .
drwxrwxr-x  3 abc abc  4 Jul 21  2021 ..
drwxr-x--- 61 abc abc 61 May 27 12:36 apps
drwxr-x---  2 abc abc  7 May 27 11:50 config
drwxr-x---  3 abc abc  4 Apr 26 07:46 themes

And on the config file itself:

root@f35d883492e5:/config# ls -alh /config/www/nextcloud/config/
total 107K
drwxr-x--- 2 abc abc    7 May 27 11:50 .
drwxr-x--- 5 abc abc    5 Jun 27  2023 ..
-rw-r----- 1 abc abc  495 Apr 26 07:46 .htaccess
-rw-r----- 1 abc abc 1.6K May 27 12:49 config.php
-rw-r----- 1 abc abc  76K Apr 26 07:46 config.sample.php
-rw-r----- 1 abc abc    2 Dec 12 23:37 mimetypealiases.json
-rw-r----- 1 abc abc    2 Dec 12 23:37 mimetypemapping.json

Everything seems correct (owner is correct and permissions match here.

I have attempted changing permissions on the config folder and files to 640, 644, 740, 744, and 777, all of which made no difference and I still received the same error. After making those changes, I ran the commands listed in the previous link (replaced “www-data” with “abc”) which also provided no resolution.

Any assistance in determining the cause and a resolution would be greatly appreciated. Please let me know what additional information would be helpful in troubleshooting.

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

Steps to replicate it:

  1. Activate terminal inside nextcloud container.
  2. run sudo -u abc php /app/www/src/occ db:add-missing-indices
  3. Error returned:
Cannot write into "config" directory!
This can usually be fixed by giving the web server write access to the config directory.

But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.
See https://docs.nextcloud.com/server/29/go.php?to=admin-config

The output of your Nextcloud log in Admin > Logging:

Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:57:31 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:57:31 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:57:31 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:57:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:57:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:57:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:57:01 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:57:01 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:57:01 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:56:31 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:56:31 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:56:31 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:56:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:56:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:56:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:55:58 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:55:58 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:55:58 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:55:28 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:55:28 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:55:28 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:55:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:55:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:55:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:54:58 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:54:58 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:54:58 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:54:23 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:54:23 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:54:23 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:54:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:54:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:54:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:53:53 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:53:53 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:53:53 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:53:22 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:53:22 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:53:22 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:53:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:53:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:53:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:52:52 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:52:52 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:52:52 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:52:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:52:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:52:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:52:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:52:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:52:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:51:51 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:51:51 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:51:51 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:51:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:51:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:51:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:51:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:51:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:51:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:50:51 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:50:51 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:50:51 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:50:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:50:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:50:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:50:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:50:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:50:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:49:51 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:49:51 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:49:51 PM"	
Debug	logreader	
Updating AppConfig: logLevel => 1
"May 27, 2024, 12:49:31 PM"	
Debug	logreader	
Updating AppConfig: shownLevels => []
"May 27, 2024, 12:49:28 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:49:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:49:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:49:21 PM"	
Debug	dav	
No calendar events found for status check
"May 27, 2024, 12:49:21 PM"	
Debug	dav	
No calendar events found for status check
"May 27, 2024, 12:49:21 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]
"May 27, 2024, 12:49:20 PM"	
Info	no app in context	
Notification was not parsed by any notifier [app: mediadc, subject: mediadc-task-alert]

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\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'redis',
    'port' => 6379,
  ),
  'datadirectory' => '/data',
  'instanceid' => 'XXX',
  'passwordsalt' => 'XXX',
  'secret' => 'XXXX',
  'trusted_domains' => 
  array (
    0 => 'nextcloud.mydomain',
  ),
  'dbtype' => 'mysql',
  'version' => '29.0.0.19',
  'trusted_proxies' => 
  array (
    0 => '10.43.1.31',
  ),
  'overwrite.cli.url' => 'https://nextcloud.mydomain',
  'overwritehost' => 'nextcloud.mydomain',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadb-nextcloud:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'dbpassword',
  'installed' => true,
... (mail settings removed)...
  'default_phone_region' => 'US',
  'updater.release.channel' => 'stable',
  'maintenance' => false,
  'loglevel' => 1,
  'theme' => '',
  'trashbin_retention_obligation' => '30,60',
  'filelocking.enabled' => 'true',
  'upgrade.disable-web' => true,
);

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.

[no app in context] Error: Exception thrown: Exception
	POST /settings/apps/enable
	from 10.43.0.1 by philip at May 27, 2024, 12:25:44 PM
[no app in context] Error: Exception thrown: Exception
	POST /settings/apps/enable
	from 10.43.0.1 by philip at May 27, 2024, 12:25:44 PM
[no app in context] Error: Exception thrown: Exception
	POST /settings/apps/enable
	from 10.43.0.1 by philip at May 27, 2024, 12:25:44 PM
[no app in context] Error: Exception thrown: Exception
	POST /settings/apps/enable
	from 10.43.0.1 by philip at May 27, 2024, 12:25:44 PM

Found my way to the Linuxserver.io Discord which led me to the container documentation. If using the Linuxserver.io Nextcloud container, don’t prepend sudo -u 123 php or it’s variants to run, run directly from docker exec. Link to relevant documentation section is here.

1 Like

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