Open Toflar opened 4 years ago
@fabpot @nicolas-grekas maybe we should dump the source path by building a path relative to __DIR__
, as we do in Symfony when dumping the container.
What do you think ?
The drawback I see is that this would make the code generation dependant on the internal cache implementation (and the fact that it is stored on the filesystem), unless the cache layer itself is responsible for performing the replacement.
I noticed this in a Symfony app but while trying to see where the error was, I noticed that it's actually Twig core behaviour. Yet reproducing it is probably easier using Symfony Flex:
composer create-project symfony/skeleton . 4.4.*
composer req twig
APP_ENV=prod ./bin/console cache:warmup
You'll see that the cache contains files along the following lines:
Actually this is the only place where I noticed absolute paths in a typical Symfony cache which causes issues if e.g. you have a chrooted SSH user and a different path in the web process.
Not sure how to fix it though. The
FilesystemLoader
seems to provide absolute file paths by contract.