error ContainerConfIgurator::__construct() must be an instance of ContainerBuilder

Created on 20 September 2022, over 2 years ago
Updated 2 December 2023, over 1 year ago

Drupal 9.4.6

rector/rector (0.13.10)
palantirnet/drupal-rector (0.13.1)

Problem / Motivation

[ERROR] Argument 1 passed to
Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConf
igurator::__construct() must be an instance of
Symfony\Component\DependencyInjection\ContainerBuilder, instance of
RectorPrefix202208\Symfony\Component\DependencyInjection\ContainerBuild
er given, called in
/.../vendor/rector/rector/vendor/symfony/depen
dency-injection/Loader/PhpFileLoader.php on line 67

Works in Upgrade Status, TO DELINEATE FIXES NEEDED but will not generate PATCH

I found a similar issue fo Rector 11.53 at https://github.com/rectorphp/rector/issues/6698 but I cannot see how it can help here

🐛 Bug report
Status

Closed: outdated

Component

Code

Created by

🇺🇸United States bobburns

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States hotwebmatter Providence, Rhode Island, USA

    For what it's worth, I've duplicated the bug on a clean install of Drupal 9.5.3 while attempting to scan my Sessionize Embed Block contrib module.

    Error message
    Error while parsing Sessionize Embed Block 1.0.1.

    Fail while processing Sessionize Embed Block 1.0.1
    Raw rector output shown below for debugging purposes. If you believe the errors are due to the tool used not the code processed, look for an existing issue or submit a new one for Drupal-rector.

     [ERROR] Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::__construct(): Argument #1
             ($container) must be of type Symfony\Component\DependencyInjection\ContainerBuilder,
             RectorPrefix202302\Symfony\Component\DependencyInjection\ContainerBuilder given, called in
             /var/www/html/vendor/rector/rector/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php on line 67

    The Rector project GitHub issue linked in the issue summary above contains a possible workaround, but it involves patching the rector.php file. Unfortunately, there are several rector.php files in my vendor directory, and it's not clear which one I should patch:

    $ find . -name rector.php                         
    ./vendor/rector/rector/vendor/rector/extension-installer/rector.php
    ./vendor/rector/rector/vendor/rector/rector-symfony/rector.php
    ./vendor/rector/rector/vendor/rector/rector-doctrine/rector.php
    ./vendor/rector/rector/vendor/rector/rector-phpunit/rector.php
    ./vendor/rector/rector/vendor/rector/rector-php-parser/rector.php
    ./vendor/rector/rector/vendor/symplify/easy-parallel/rector.php
    ./vendor/rector/rector/bin/rector.php
    ./vendor/drush/drush/rector.php
    ./vendor/palantirnet/drupal-rector/rector.php
    
  • 🇺🇸United States agentrickard Georgia (US)

    They probably mean the rector.php file in your project root.

  • Status changed to Postponed: needs info about 2 years ago
  • 🇺🇸United States agentrickard Georgia (US)

    You should also try updating to release 15, which might have fixed the issue.

    Once we make newer releases, older releases are no longer supported, since Rector itself frequently introduces breaking changes.

    Please update your installation and report back.

  • Status changed to Closed: works as designed about 2 years ago
  • 🇺🇸United States moshe weitzman Boston, MA

    I got this error too. I had to re-run the copy for this project - cp vendor/palantirnet/drupal-rector/rector.php .

  • 🇩🇪Germany tfranz

    I got this error, too:

    [ERROR] Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::__construct(): Argument #1
             ($container) must be of type Symfony\Component\DependencyInjection\ContainerBuilder,
             RectorPrefix202302\Symfony\Component\DependencyInjection\ContainerBuilder given, called in
             /var/www/html/vendor/rector/rector/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php on line 67

    Drupal 9.5.3
    rector/rector 0.15.18
    palantirnet/drupal-rector: 0.15.1
    drupal/upgrade_rector: 1.0.0-alpha8

  • Status changed to Active about 2 years ago
  • 🇺🇸United States euk

    It doesn't work for me. Using Drupal 9.4.10.

    Can somebody please provide definitive steps to fix this issue?
    Copying rector.php doesn't help.

  • 🇮🇳India sarikak

    Any solution?

  • 🇮🇳India sarikak

    Any solution?

  • 🇺🇸United States kwfinken Lansing, MI

    Still an issuecd :

     [ERROR] Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConf
             igurator::__construct(): Argument #1 ($container) must be of type
             Symfony\Component\DependencyInjection\ContainerBuilder,
             RectorPrefix202304\Symfony\Component\DependencyInjection\ContainerBuild
             er given, called in
             /opt/drupal/vendor/rector/rector/vendor/symfony/dependency-injection/Lo
             ader/PhpFileLoader.php on line 67
    

    I tried cp /opt/drupal/vendor/palantirnet/drupal-rector/rector.php /opt/drupal but to no avail.

  • 🇮🇳India Sana.Neyazi

    I am also getting this same issue. Copying rector.php (cp vendor/palantirnet/drupal-rector/rector.php ) and pasted at project root but it doesn't help

    [ERROR] Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::__construct(): Argument #1
             ($container) must be of type Symfony\Component\DependencyInjection\ContainerBuilder,
             RectorPrefix202302\Symfony\Component\DependencyInjection\ContainerBuilder given, called in
             /var/www/html/vendor/rector/rector/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php on line 67
  • 🇲🇽Mexico eliasdelatorre

    Getting the same issue when running rector against a custom module, tried copying rector.php file as directed, but issue still happening in said custom module and contrib modules like Address, Admin Toolbar and GraphQL:

     [ERROR] Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::__construct(): Argument #1
             ($container) must be of type Symfony\Component\DependencyInjection\ContainerBuilder,
             RectorPrefix202304\Symfony\Component\DependencyInjection\ContainerBuilder given, called in
             /app/vendor/rector/rector/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php on line 67
    
  • 🇵🇹Portugal JonasSavs

    Hey all,

    I was able to fix this issue by copying:

    cp ./vendor/palantirnet/drupal-rector/rector.php ./web/modules/contrib/upgrade_rector/rector-config-template.php

    Hope it helps you all.

  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States mlncn Minneapolis, MN, USA

    JonasSavs answer in #15 fixed it for us. Is that something that can be patched?

  • 🇺🇸United States jmarkel

    Also jumping in to say that JonasSavs answer (in #15) fixed it for me.

  • 🇦🇺Australia gordon Melbourne

    #15 resolved it for me, but I have also created a patch so that I can included this to make it repeatable when I install this.

  • 🇧🇪Belgium jonas139

    I can also acknowledge that #15 fixed the issue!

  • Status changed to Needs review over 1 year ago
  • 🇵🇰Pakistan khurrami

    Thanks #15 worked for me as well.

  • Status changed to Closed: outdated over 1 year ago
  • 🇳🇱Netherlands bbrala Netherlands

    Seems fixed. Thanks for checking

Production build 0.71.5 2024