0

Upgraded Magento version to 2.4.4-p2 whenever we move files from local to server even any folder to another folder at same server, shows below error. We do every time vendor folder delete then run composer install command to fix it, but why this happens, please guide us.

vendor/composer/../thecodingmachine/safe/generated/apache.php): Failed to open stream: No such file or directory in /home/username/public_html/staging_site/vendor/composer/autoload_real.php on line 59

2 Answers 2

0

Try running the composer dump-autoload command instead of composer install. This command regenerates the autoload files without installing any new packages, and may help to resolve any issues with the autoload configuration.

4
  • i already try this command but not resolved
    – Sourav
    Commented Mar 28, 2023 at 6:01
  • Check that the vendor directory and all of its contents have been uploaded correctly to the server. If any files are missing or corrupt, this could cause issues with the autoload configuration.
    – Harun
    Commented Mar 28, 2023 at 6:03
  • No, all files are fine
    – Sourav
    Commented Mar 29, 2023 at 8:58
  • Did you find any solution for this? @Sourav
    – mechanic
    Commented May 24, 2023 at 15:04
0

My guess is that this has happened because when you move files, you are most likely excluding the /generated folder. But whatever method you are using, it is not just excluding /generated, but also folders named generated, even if they are many levels down. To resolve it, just remove the affected folder (rm -r vendor/thecodingmachine/) and run composer install again.

I had run across this when backing up a site using restic and doing a test restore. Specifically, I was excluding the generated folder in the backups. To prevent this error from happening, I had to include a leading slash to the exclude argument to anchor it to the root of the project. E.g. --exclude="/generated" instead of --exclude="generated"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.