Skip to content

Cache warmup on network drives creates inaccessible application paths [only windows?] #42242

Closed
@JPustkuchen

Description

@JPustkuchen

Symfony version(s) affected: 5.3.x

Description
Cache clear with warmup on console is very helpful, but may lead to unexpected results, if executed on a (windows) network drive!
I guess this can only happen on Windows by path logic, but we should also ensure it's impossible to happen on Linux.

TL;DR;
cmd cache warmup commands (direct or indirect) build the cached application file paths based on the current bash directory, while the web server will not know this path, as it may be only client-side.

So when running the application, the web server tries to load files from Z:\ (client network drive where cmd was run) while it should be C:\ (web server drive) - even worse: Z:\ could be a totally different drive on the server.

The problem becomes even more important as Composer has a problem with proc_open / UNC path which will lead many people on Windows to use a network drive as a workaround. See https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-failed-to-open-stream-errors-windows-

Background:
A customer is running a small Symfony project on a Windows server using XAMPP (I know - no good idea for local production, but not my choice and has nothing to do with this bug report).
Whenever I ran the application with DEBUG=0 (debug enabled doesn't use the twig error pages override) I got an Error 500 and in Log:

The "Z:\directoryname/templates/bundles/TwigBundle" directory does not exist ("Z:\directoryname/templates/bundles/TwigBundle")." at C:\xampp\htdocs\directoryname\vendor\twig\twig\src\Loader\FilesystemLoader.php line 92

But the directory was definitely existing! I recognized the web server used the Z:\ network drive defined on my client instead of the server directory path. Clearing the cache with --no-warmup finally solved the problem!

How to reproduce
Run a web server on Windows on a remote machine accessible by network drive from the client
As example, override an error page using this guide with an error.html.twig: https://symfony.com/doc/current/controller/error_pages.html#custom-error-controller - Unsure in which other situations the error may appear due to cached paths
Deploy the application to the network drive and run php bin/console cache:clear (without --no-warmup)

Possible Solution
a) Fix the root cause (unsure if that's even possible) and if it's deeper connected to the twig error pages override special case
or
b) Warn the user when creating caches in bat on a network drive (if that's detectable)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions