Command: occ files:scan --all, returns: "stat: cannot statx 'file-name-with-special-characters': No such file or directory"

Nextcloud version: 22.2.0
Operating system and version: Arch Linux ARM Raspberry PI 4
Apache or nginx version: Apache 2.4.51
PHP version: 8.0.12

The issue you are facing: When running the command occ files:scan --all the error message: stat: cannot statx 'file-name-with-special-characters': No such file or directory appear to every file with special characters, like á or à.

Is this the first time you’ve seen this error?: Y

Steps to replicate it:

  1. Run the command occ files:scan --all

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

<?php
$CONFIG = array (
  'datadirectory' => '/shared/nextcloud/data',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/usr/share/webapps/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/lib/nextcloud/apps',
      'url' => '/wapps',
      'writable' => true,
    ),
  ),
  'instanceid' => '***',
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' =>
  array (
    0 => '***',
  ),
  'dbtype' => 'mysql',
  'version' => '22.2.0.2',
  'overwrite.cli.url' => '***',
  'htaccess.RewriteBase' => '/',
  'overwriteprotocol' => 'https',
  'dbname' => '***',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '***',
  'dbpassword' => '***',
  'installed' => true,
  'default_phone_region' => 'BR',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/run/redis/redis.sock',
    'port' => 0,
  ),
  'maintenance' => false,
  'mail_smtpmode' => '***',
  'mail_smtpsecure' => '***',
  'mail_sendmailmode' => '***',
  'mail_from_address' => '***',
  'mail_domain' => '***',
  'mail_smtpauthtype' => '***',
  'mail_smtpauth' => ***,
  'mail_smtphost' => '***',
  'mail_smtpport' => '***',
  'mail_smtpname' => '***',
  'mail_smtppassword' => '***',
);

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

...
stat: cannot statx '/shared/nextcloud/data/***': No such file or directory
stat: cannot statx '/shared/nextcloud/data/***': No such file or directory
stat: cannot statx '/shared/nextcloud/data/***': No such file or directory
stat: cannot statx '/shared/nextcloud/data/***': No such file or directory
stat: cannot statx '/shared/nextcloud/data/***': No such file or directory
stat: cannot statx '/shared/nextcloud/data/***': No such file or directory
...

Did you check the file names for invalid special chars?
Some German, French and Eastern European special chars may lead into trouble as well as colon, quotation marks, “=”, “`”, “(”, “)” or “{”, “}” and more.
In those cases the file names should be renamed.

Yes, i checked, the problem are special characters like:

Example:
/shared/nextcloud/data/myuser/Dia das Mães/photo.png

In the logs, this error message appears: stat: cannot statx '/shared/nextcloud/data/data/myuser/Dia das Mes/photo.png': No such file or directory
Notice how the ã character is cut off on the log message.

Please find this thread for further information:
https://help.nextcloud.com/t/windows-illegal-filename-characters-cant-find-the-github-bug-report/117924/12

File- and folder names with special chars very often lead to problems.
So I recommend to rename the files and folders by replacing the spacial chars with “_” and instruct the users, not to use special chars anymore.

I’m syncing a folder with 52k files, lots of them with special characters, I think I’ll wait for some official solution, maybe a script that can automate this replacement of special characters.