Magento2 – Warning in generated/code/Magento/Framework/App/Config/InitialConfigSource/Proxy.php

magento2

This is killing me.

When I run bin/magento setup:upgrade it throws this:

Warning:
include(/vendor/composer/../../generated/code/Magento/Framework/App/Config/InitialConfigSource/Proxy.php):
failed to open stream: No such file or directory in
/vendor/composer/ClassLoader.php on line 444

And when I run bin/magento setup:di:compile it throws this:

Class Magento\Framework\App\ResourceConnection\Proxy does not exist

Site was running perfectly. I had run setup:upgrade before without any problem. I had also ran di:compile.

But today, all of sudden this is happening.

Any idea?

UPDATE

I used to follow this every time when I compile:
https://devdocs.magento.com/guides/v2.3/performance-best-practices/deployment-flow.html

Could it be the reason now that I cannot run bin/magento setup:upgrade or bin/magento setup:di:compile?

I remember, at first running bin/magento setup:upgrade it threw error, after that I am stuck, couldn't run any CLI commands.

UPDATE 2

On first run setup:upgrade, it threw an error. Unfortunately I did not make a note of that and re-run the setup:upgrade again. Since then the above-mentioned error is thrown.

UPDATE 3

Alright, so in my local instance, I was able to reproduce a similar error. It's slightly different than what I was getting in my live server:

Warning:
include(/vendor/composer/../../generated/code/Magento/Framework/App/ResourceConnection/Proxy.php):
failed to open stream: No such file or directory in
/vendor/composer/ClassLoader.php on line 444

So, after I ran composer update It did allow me to run Magento CLI commands. And I was able to compile.

I still want to understand this. I am yet to perform this into my live server.

Best Answer

If you use dockergento try

dockergento composer dump-autoload
 docker exec -it -u 0 hp_redis_1 bash

Then inside

redis-cli flushall
exit

and then run setup:upgrade . If you don't use dockergento it might be something similar for bin magento. first try bin/magento composer dump-autoload.