[Solved] Ran `nextcloud.occ config:system:set` without --value flag and now in a bad state

Nextcloud version (eg, 20.0.5): 22.2.3snap3
Operating system and version (eg, Ubuntu 20.04): Ubuntu 18.04
Apache or nginx version (eg, Apache 2.4.25): unsure
PHP version (eg, 7.4): unsure

The issue you are facing:

I attempted to reconfigure the location of the logs from their default location. I mistakenly ran the config:system:set command without the --value= flag and I’m now in a bad state. I’ve attempted to modify config.php manually, but even with sudo the file is readonly.

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

Steps to replicate it:

  1. Run the command `sudo nextcloud.occ config:system:set logfile /path/to/log/nextcloud.log
$ sudo nextcloud.occ config:system:set logfile /var/log/nextcloud.log
System config value logfile => /var/log/nextcloud.log set to empty string
  1. Run any OCC command
$ sudo nextcloud.occ config:system:get logfile
An unhandled exception has been thrown:
TypeError: OC\Log\File::__construct(): Argument #1 ($path) must be of type string, array given, called in /snap/nextcloud/29249/htdocs/lib/private/Log/LogFactory.php on line 87 and defined in /snap/nextcloud/29249/htdocs/lib/private/Log/File.php:58
Stack trace:
#0 /snap/nextcloud/29249/htdocs/lib/private/Log/LogFactory.php(87): OC\Log\File->__construct()
#1 /snap/nextcloud/29249/htdocs/lib/private/Log/LogFactory.php(58): OC\Log\LogFactory->buildLogFile()
#2 /snap/nextcloud/29249/htdocs/lib/private/Server.php(752): OC\Log\LogFactory->get()
#3 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#4 /snap/nextcloud/29249/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#5 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#6 /snap/nextcloud/29249/htdocs/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#7 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(87): OC\ServerContainer->query()
#8 [internal function]: OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#9 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(106): array_map()
#10 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(114): OC\AppFramework\Utility\SimpleContainer->buildClass()
#11 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(131): OC\AppFramework\Utility\SimpleContainer->resolve()
#12 /snap/nextcloud/29249/htdocs/lib/private/ServerContainer.php(161): OC\AppFramework\Utility\SimpleContainer->query()
#13 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#14 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(182): OC\AppFramework\Utility\SimpleContainer->get()
#15 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#16 /snap/nextcloud/29249/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#17 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#18 /snap/nextcloud/29249/htdocs/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#19 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(87): OC\ServerContainer->query()
#20 [internal function]: OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#21 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(106): array_map()
#22 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(114): OC\AppFramework\Utility\SimpleContainer->buildClass()
#23 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(131): OC\AppFramework\Utility\SimpleContainer->resolve()
#24 /snap/nextcloud/29249/htdocs/lib/private/ServerContainer.php(161): OC\AppFramework\Utility\SimpleContainer->query()
#25 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(87): OC\ServerContainer->query()
#26 [internal function]: OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#27 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(106): array_map()
#28 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(114): OC\AppFramework\Utility\SimpleContainer->buildClass()
#29 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(131): OC\AppFramework\Utility\SimpleContainer->resolve()
#30 /snap/nextcloud/29249/htdocs/lib/private/ServerContainer.php(161): OC\AppFramework\Utility\SimpleContainer->query()
#31 /snap/nextcloud/29249/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#32 /snap/nextcloud/29249/htdocs/lib/private/Server.php(1416): OC\AppFramework\Utility\SimpleContainer->get()
#33 /snap/nextcloud/29249/htdocs/lib/private/Server.php(1382): OC\Server->connectDispatcher()
#34 /snap/nextcloud/29249/htdocs/lib/base.php(593): OC\Server->__construct()
#35 /snap/nextcloud/29249/htdocs/lib/base.php(1089): OC::init()
#36 /snap/nextcloud/29249/htdocs/console.php(48): require_once('...')
#37 /snap/nextcloud/29249/htdocs/occ(11): require_once('...')
#38 {main}%

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

# ubuntu @ raspberry_pi in /snap/nextcloud/current/htdocs/config [7:27:39]
$ cat config.php
<?php

$snap_current = getenv('SNAP_CURRENT');
$snap_data_current = getenv('SNAP_DATA_CURRENT');

$CONFIG = array(
/**
 * Use the ``apps_paths`` parameter to set the location of the Apps directory,
 * which should be scanned for available apps, and where user-specific apps
 * should be installed from the Apps store. The ``path`` defines the absolute
 * file system path to the app folder. The key ``url`` defines the HTTP web path
 * to that folder, starting from the Nextcloud web root. The key ``writable``
 * indicates if a web server can write files to that folder.
 */
'apps_paths' => array(
        /**
         * These are the default apps shipped with Nextcloud. They are read-only.
         */
        array(
                'path'=> $snap_current.'/htdocs/apps',
                'url' => '/apps',
                'writable' => false,
        ),

        /**
         * This directory is writable, meant for apps installed by the user.
         */
        array(
                'path'=> $snap_data_current.'/nextcloud/extra-apps',
                'url' => '/extra-apps',
                'writable' => true,
        ),
),

/**
 * Database types that are supported for installation.
 *
 * Available:
 *      - sqlite (SQLite3 - Not in Enterprise Edition)
 *      - mysql (MySQL)
 *      - pgsql (PostgreSQL)
 *      - oci (Oracle - Enterprise Edition Only)
 */
'supportedDatabases' => array(
        'mysql',
),

'memcache.locking' => '\OC\Memcache\Redis',
'memcache.local' => '\OC\Memcache\Redis',
'redis' => array(
    'host' => getenv('REDIS_SOCKET'),
    'port' => 0,
),

'log_type' => 'file',
'logfile' => $snap_data_current.'/logs/nextcloud.log',
'logfilemode' => 0640,
);

It turns out where I thought the config.php file lived was not the real config.php file. I found the actual config file (in /var/snap/nextcloud/current/nextcloud/config.php) and corrected the errant logfile entry.