I added files to Nextcloud via the filesystem, so the files are not known to Nextcloud.
I intended to use occ files:scan to tell Nexctloud about the files in this way:
# sudo -u nextcloud php7.4 /var/www/nextcloud/occ files:scan --path="wbk/files/"
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:87
.... (stacktrace)
It does not work. I tried:
running as root, sudo -u nextcloud as above
running as root, sudo -u www-data
using another PHP version
php7.0 : this Nextcloud needs 7.3 at least
php7.3 : OC\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)
php7.4 as above
php without version, defaults to 7.4, so same result
with absolute path or relative path for both php and the data path, all 4 combinations
In some combination I got a warning about config.php being read only, but the option 'config_is_read_only' => true, is in the file.
Maybe that you should use php7.3 with option --define apc.enable_cli=1. So it should be something like sudo -u nextcloud php7.3 --define apc.enable_cli=1 /var/www/nextcloud/occ files:scan --path="wbk/files/".
Starting scan for user 1 out of 1 (wbk)
Exception during scan: opendir(/home/yunohost.app/nextcloud/data/wbk/files/InstantUpload/Conv6ations Videos): failed to open dir: Permission denied
which was gone after # chown -R nextcloud:nextcloud /home/yunohost.app/nextcloud/data/wbk/files/
# sudo -u nextcloud php7.3 --define apc.enable_cli=1 /var/www/nextcloud/occ files:scan --path="wbk/files/"
Starting scan for user 1 out of 1 (wbk)
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 198 | 5003 | 00:00:07 |
+---------+-------+--------------+