I have a few templates that are failing when compiling them in twig. What is happening is that the \Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage::save method will create a temporary file like files/php/twig/.0c781c5196 and then it tries to rename this file into something like files/php/twig/DIRECTORY/FILE.php but it fails with No such file or directory.
The target directory exists, it even has .htaccess. On each page refresh, I get different temporary and target file names.
I tried to manually copy and rename the file but on each page load the ID's change so it never works.
The template hasn't been edited and it always worked just fine(it renders properly even without compiled twig). Any idea what can be causing this?
It looks like this is only a single template issue. Due to the ever changing IDs, I thought there were more.
This is happening on my local windows machine right now so I though there might be an issue with those crazy long directory and file names but I can manually rename the file.
The length of the directory name is 134 characters which are well below 260 maximum.
UPDATE 27.6: I have experienced this same issue on another Drupal 8 project. So it looks like it is not a unique problem but rather universal but I still haven't figured out what the issue is.