Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot autowire service xx .. no such service exists #6369

Closed
JanMikes opened this issue May 6, 2021 · 8 comments
Closed

Cannot autowire service xx .. no such service exists #6369

JanMikes opened this issue May 6, 2021 · 8 comments
Labels

Comments

@JanMikes
Copy link
Contributor

JanMikes commented May 6, 2021

Bug Report

Subject Details
Rector version dev-main @ 3b82c87
Installed as rector/rector composer dependency
❯ vendor/bin/rector

 [ERROR] Cannot autowire service "Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector": argument
         "$testsNodeAnalyzer" of method "__construct()" references class "Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer"
         but no such service exists.

This error is on main branch. Tried with stable version but with that i got other error:

 [ERROR] Cannot autowire service "Rector\NetteToSymfony\NodeAnalyzer\ClassMethodRenderAnalyzer": argument
         "$thisTemplatePropertyFetchAnalyzer" of method "__construct()" references class
         "Rector\Nette\NodeAnalyzer\ThisTemplatePropertyFetchAnalyzer" but no such service exists.

Minimal PHP Code Causing Issue

Config:

return static function (ContainerConfigurator $containerConfigurator): void {
    $parameters = $containerConfigurator->parameters();
    $parameters->set(Option::SETS, [SetList::DEAD_CODE]);
};

Expected Behaviour

I expect to not fail 😄

It does not fail on getrector.org because there is old version deployed (0.10.1)

@JanMikes JanMikes added the bug label May 6, 2021
@JanMikes
Copy link
Contributor Author

JanMikes commented May 6, 2021

I checked, the class exists in my vendor directory.

@TomasVotruba
Copy link
Member

Hey :), first I would remove composer.lock and call:

composer install

We're using composer plugin to add packages so composer update and old rector won't work together.

@TomasVotruba
Copy link
Member

Today I broke Docker, so it might be related too: https://github.com/rectorphp/rector-prefixed/runs/2518376132

@JanMikes
Copy link
Contributor Author

JanMikes commented May 6, 2021

rm -rf vendor composer.lock

And no change.

Though we are running with --no-scripts because we need to disable symfony/flex. Will try without that parameter.

@TomasVotruba
Copy link
Member

Though we are running with --no-scripts because we need to disable symfony/flex. Will try without that parameter.

👍

@JanMikes
Copy link
Contributor Author

JanMikes commented May 6, 2021

In 0.10.19 issue is that rector/rector-nette-to-symfony package is not installed (im not sure why i need it anyways).

In dev-main without --no-scripts it works, this appears in composer install command output:

ssch/rector-extension-installer: Extensions installed
> rector/rector-cakephp: installed
> rector/rector-doctrine: installed
> rector/rector-laravel: installed
> rector/rector-nette: installed
> rector/rector-phpunit: installed
> rector/rector-symfony: installed

Though it breaks other things in our applications, what are manual steps that have to be done in order to make it work with --no-scripts please?

@TomasVotruba
Copy link
Member

In 0.10.19 it was still part of core. It was extracted yesterday.

im not sure why i need it anyway

It's needed for downgraded/scoped release, see: #5976

what are manual steps that have to be done in order to make it work with --no-scripts please?

Probably include configs with those services in rector.php. But this would require further maintenance in the future with randomly missing services :)

What other parts does Rector break?

@JanMikes
Copy link
Contributor Author

JanMikes commented May 6, 2021

What other parts does Rector break?

Not rector, but other composer packages, that does "something" without --no-scripts 😄

I think we can close as the issue is solved - i will find a way how to work around including configs 😉 thank you for your effort.

@JanMikes JanMikes closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants