Skip to content

Internal error: Cannot rename on Windows #12460

@mickverm

Description

@mickverm

Bug report

When switching branches, I often run into the following error when using PHPStan on Windows, which makes me have to rerun the PHPStan command a second time:

     Internal error: Cannot rename "C:\Users\Mickverm\Documents\project\var\cache\dev\App982.tmp" to                                                      

     "C:\Users\Mickverm\Documents\project/var/cache/dev/App_KernelDevDebugContainer.php.meta.json":                                                       

     rename(C:\Users\Mickverm\Documents\project\var\cache\dev\App982.tmp,C:\Users\Mickverm\Documents\project/var/cache/dev/App_KernelDevDebugContainer.php.meta.json):
     Access is denied (code: 5) while analysing file C:\Users\Mickverm\Documents\project\src\Controller\UserController.php

     Run PHPStan with -v option and post the stack trace to:                                                                                                             

     https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml                                                                                              

 [ERROR] Found 7 errors

⚠️  Result is incomplete because of severe errors. ⚠️
   Fix these errors first and then re-run PHPStan
   to get all reported errors.

I'm not sure if this is related to PHPStan itself or phpstan-symfony, seeing as all errors occur in the /var/cache/dev directory of the Symfony project.
The issue is a little hard to reproduce since it doesn't always happen.

This looks similar to issues that can be found in the Rector and Symfony repositories:

Code snippet that reproduces the problem

Not something we can reproduce on phpstan.org/try

Expected output

PHPStan runs first try without any severe errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions