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

Rector in Docker autoload issue #5003

Closed
andrey-mostovoy opened this issue Dec 26, 2020 · 4 comments
Closed

Rector in Docker autoload issue #5003

andrey-mostovoy opened this issue Dec 26, 2020 · 4 comments
Assignees

Comments

@andrey-mostovoy
Copy link

For those who faced with error
[ERROR] Call to undefined method Symfony\Component\DependencyInjection\ContainerBuilder::autowire()
even doing command like this
docker run --rm -v $(pwd):/project rector/rector:latest list

Try to add --workdir "/rector", so the command will be
docker run --rm -v $(pwd):/project --workdir "/rector" rector/rector:latest list

And for command process you should add --autoload-file=/project/vendor/autoload.php for autoloading your project files.

Notice, /project - its a volume inside the docker container, where you mounted your code

@TomasVotruba
Copy link
Member

Hi,

thanks for the feedback.
Could you update the README.md so other can use this knowledge?

@JanMikes
Copy link
Contributor

Hi. I think that this is a "feature, not a bug" situation 😄

Can you Share what symfony version does your application use? I am specifically asking if Symfony\Component\DependencyInjection\ContainerBuilder::autowire() exists in your codebase.

It makes me think, that you just faced version mismatch - rector uses newer version of symfony, than your application requires in composer.json - this is usually solved using prefixed rector, unfortunately docker image does not use prefixed, but "classic" rector dependency, just installed globally.

Your workaround works, because if you change workdir to rector, it gets higher priority for autoloading and rector files are autoloaded first and same class but from different directory (your project's vendor) will not get autoloaded anymore, because it is loaded already.

Your solution might work for someone and maybe for someone else not - it is unexplored area 😄

@andrey-mostovoy
Copy link
Author

Hi. This one "feature" not on symfony application... But we have in project some symfony components....

$ composer info | grep depen
php-di/php-di                            6.0.11             The dependency injection container for humans
symfony/dependency-injection             v3.1.10            Symfony DependencyInjection Component

this one symfony/dependency-injection installed as a dependency of someone other package...

You are right about unexplored area ))

@TomasVotruba
Copy link
Member

Continue in far developed issue #5593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants