This seems to happen for whatever reasons – the server file list is not in sync with the local file list and cannot even be modified manually. This may be a particular problem when you are at 1&1 /ionos with a hosted package. Here is a solution
$path = realpath(dirname(__FILE__)); #exec("php $path/console.php upgrade 2>&1", $out, $result); exec("php $path/console.php files:scan --all -v 2>&1", $out, $result); echo "<pre>result: " .$result .PHP_EOL; print_r($out);