Skip to content

Exception while clearing cache in 5.2.0-BETA1 #38547

@BoShurik

Description

@BoShurik

Symfony version(s) affected:5.2.0-BETA1

Description
Exception Cannot rename because the target ".../var/cache/de~" already exists.

How to reproduce
Every second run bin/console c:c will fail

Possible solution
The problem is in

https://github.com/symfony/symfony/blob/5.x/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php#L164-L173

if ($oldBuildDir) { // /var/cache/de~
    $fs->rename($realBuildDir, $oldBuildDir);
} else {
    $fs->remove($realBuildDir);
}
if ($oldCacheDir) { // /var/cache/de~
    $fs->rename($realCacheDir, $oldCacheDir); // Exception
} else {
    $fs->remove($realCacheDir);
}

$oldBuildDir and $oldCacheDir is equal

Additional context
This bug was introduced in #36515
/cc @mnapoli

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