First of all, there was this issue posted for Symfony here: https://github.com/symfony/symfony/issues/19363 . I encountered the same thing and spent a lot of time investigating it and came up to this:
When using FileCache filenames sometimes are longer, than supported. I am using docker containers on vagrant with VBox linked shared folders. There is a limit for a FILE_NAME
of 255 characters.
I tried renaming some of the long filenames inside cache directories and the error switched to another folder:
/var/www/html/var/cache/de~/annotations/fd
-> var/www/html/var/cache/de~/annotations/44
for example. So it looks like command is able to process the first folder, but then fails on the second one, as there is also a very long filename (256 characters including extension, which should be 255).
I am using docker containers on vagrant with VirtualBox and I suspect that the vboxsf might have some FILE_NAME or PATH_NAME limitations and those are 255 and 4096 respectively.
Then I tried to reduce filenames from 256 chars and went to Doctrine\Common\Cache\FilesystemCache
and changed extension from .doctrinecache.data
to .doctrine.data
and everything worked, I was able to clear the cache after clearing the previous one manually (it still had long files).
It led me to suspect, that the problem lies within Doctrine\Common\Cache\FileCache
, getFilename()
does not work properly and sometimes has wrong behaviour. I think this issue is also connected to #174 .
IMPORTANT: Issue persists only for Symfony dev environment and works fine for prod.