Rector: dev-master (reproduced with 0.5.3 and 0.6)
PHP: 7.3
Could not process file due to "Kernel "App\Kernel" could not be instantiated for: The service "templating.loader.cache" has a dependency on a non-existent service "templating.loader.wrapped"..
Current environment is "dev". Try changing it in "parameters > kernel_environment" in rector.yaml".
What happens when you change the environment to "test" or others you have?
same issue
Spent some more time on this, Even cloning a fresh symfony4 repo and then running rector on it produces the same error
I see. This error is hard to find, as it's related only to your specific project.
What I'd suggest is to ignore Rector rule, that is causing this error:
https://github.com/rectorphp/rector#exclude-paths-and-rectors
I will be somethiing from symfony set, related to get container.
Try ignoring one after another, to find it
Shouldn't happen on a fresh symfony 4 clone though so i wouldnt say its related only to my project.
Agreed. If you're able to figure out the rule(s) that is causign it, we'll be able to narrow it down and fix.
By Symfony 4 project you mean symfony/demo?
Could you pass here full git/composer script to reproduce? E.g.
git clone [email protected]:symfony/demo.git
cd demo
composer require rector/rector --dev
vendor/bin/rector process src/Controlller --set symfony32 --dry-run
symfony new Web2 --full --version=lts
cd Web2
composer require rector/rector --dev
cp ../rector.yaml .
./vendor/rector/rector/bin/rector process src -c rector.yaml
Contents of rector.yaml
parameters:
autoload_paths:
- config/bootstrap.php
sets:
- symfony-constructor-injection
What does:
symfony new Web2 --full --version=lts
stand for in Git? I never used it and having purelly git solution would make it easier for me
So I am brand new to Rector, but not to Symfony. I have a couple of dozen Symfony apps on various versions that have been around for years, and I am very interested to use Rector on them to ease upgrades.
I am getting this same error, and many similar errors, to it. I can fix the errors one by one, but I am following to see if there's a more general fix.
Basically, the templating.loader.wrapped service is only created if you enable cache configuration via your framework.templating.cache configuration in Symfony. You can see the code for creating the service here:
https://github.com/symfony/symfony/blob/4.4/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L992
It only gets invoked if the cache configuration value is true. If it is, then Symfony makes the templating.loader.wrapped service, otherwise it does.
You can see the templating.loader.wrapped service being decorated here:
https://github.com/symfony/symfony/blob/4.4/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml#L54
Basically Symfony "loads" just fine normally, but it fails in Rector, because it cannot make the templating.loader.cache service, even though Symfony when used normally has no problem with that.
I have hit 2-3 of the same type of error, where Rector is erroring out on services that do not exist always in Symfony, and are only dynamically created based on configuration.
Here's how to set up a test case:
Install the symfony binary:
https://symfony.com/download
Sorry, I know you prefer a git solution, but I have very limited git experience. The symfony command is basically a stand in for composer create-project symfony/website-skeleton rector-test 4.4.*
Create a new full symfony app based on 4.4:
symfony new --full rector-test 4.4
Navigate to that directory, and add in rector:
composer require rector/rector --dev
Then run the code quality set (it's the EventListenerToEventSubscriberRector that causes the issue, I believe)
php vendor/rector/rector/bin/rector process src --set=symfony-code-quality
Here is the error:
[ERROR] Could not process "/path/to/project/rector-test/src/Kernel.php" file, due to:
"Kernel "App\Kernel" could not be instantiated for: The service "translator.logging" has a dependency on a
non-existent service "translator.logging.inner"..
Current environment is "dev". Try changing it in "parameters > kernel_environment" in rector.yaml".
Note this a different service than the one above, but it's the same thing. translator.logging.inner is only created if you set framework.translator.logging to on. So there's something going on that's causing Rector to error on invalid services, even when Symfony does not.
I'm looking into this now...
composer create-project symfony/website-skeleton
cd website-skeleton
composer require rector/rector --dev
vendor/bin/rector
# 0.6.1
vendor/bin/rector p src --set symfony-code-quality --dry-run