- Issue created by @jnicola
- 🇬🇧United Kingdom catch
lib/Drupal.php). Drupal::getContainer() (Line: 414) Drupal::config() (Line: 56) include_once() (Line: 184)
This looks like the problem. It seems that you have some code somewhere that is calling \Drupal::config() when a file is included (outside a class or function context). If you can find out where that is, that will help a lot to track this down.
Enabling xdebug in ddev may help to get more backtrace information.
- 🇺🇸United States jnicola
So I searched for \Drupal::config() inside all of modules and themes, found nothing. I'll see about xdebug for additional backtrace.
I'm seeing similar issues pop up accross a multitude of other modules like this:
https://www.drupal.org/project/launch_checklist/issues/3498288#comment-1... 🐛 "$container is not initialized yet" errors following upgrade to D11.1.0 ActiveIn that case the issue stemmed from:
include \Drupal::service('extension.list.module')->getPath('launch_checklist') . '/inc/routes.inc';
Granted, I am not using that particular module, but am seeing these issues out there.
I have the same problem. The only difference is that I am experiencing this problem with the field encrypt module. When I remove field encrypt, the problem goes away. When I activate it, I experience it again. Usually, with the Drush updb command...
- 🇬🇧United Kingdom catch
@jnicola can you check for hook_module_implements_alter()
🐛 \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. Active looks similar-ish.
- 🇬🇧United Kingdom catch
🐛 Kint breaks drush updb for Drupal CMS Active looks like the exact error you're getting.
- 🇺🇸United States jnicola
Ah yep, Kint was indeed my issue. Disabling it has allowed me to proceed.
I do think it's worth noting and continuing to discuss here that some change between 11.0 and 11.1 is causing this issues for a bunch of contrib modules and breaking site upgrades for folks. It's also not terribly easy to troubleshoot with the current error output, even with backtrace. What changed in core that resulted in this sort of sensitivity across a variety of modules? Can anything be done to address this better and/or useful error output to inform module developers of their issue?
- 🇺🇸United States nicxvan
@pearls field_encrypt needs 📌 Migrate to OOP hooks Needs review and 📌 Support OOP hooks Active to be ready for 11.1.
@jnicola
bunch of contrib modules and breaking site upgrades for folks
So far I am aware of three modules that broke. It's helpful to identify them so we can help maintainers update!
It's also not terribly easy to troubleshoot with the current error output, even with backtrace
I agree, so far one only seen this with modules doing something in hook module implements alter.
Unfortunately for oop hooks we need to execute hmia but it happens at a time that a lot of things are not available. It is in the breaking changes section of the oop change record.
Most modules are doing something unnecessary and it's an easy fix. Field encrypt is an exception and harder to fix. - 🇺🇸United States jnicola
Fair fair, well, let's see what comes in as more folks run into this and troubleshoot it, and thanks for everyones time!
- 🇺🇸United States nicxvan
Also @jnicola, did you search for
\Drupal::config()
or\Drupal::config(
it has an argument so if you searched the former the kint implementation would not show up but the latter would. - 🇺🇸United States nicxvan
I wonder if it's worth putting something in the cr about calling services directly.
Can we improve the error messaging?
- 🇬🇧United Kingdom catch
Could we try/catch the exception when executing hmia/including the modules and add the module name to the error message?
Or could we even eat the exception and trigger_error() instead?
- 🇳🇱Netherlands johnv
The office_hours module suffered/suffers from this problem.
See
🐛 Drupal 11.1 Crash Active and follow up Child issues.The module included 2 files from the .module files itself, after removing that, and including all books in the module file, a Follow up was encountered for a nested included. Removed that as well.
Now, the 2nd theming file is still not included, as reporter by a user. - 🇳🇱Netherlands johnv
The office_hours.module.file.now contains this one line, and the theme file seems not to be loaded.
// Include file, avoiding container error during upgrade. if (\Drupal::hasContainer()) { // Add theme.api.php hooks. \Drupal::moduleHandler()->loadInclude('office_hours', 'inc', 'office_hours.theme'); }
- 🇳🇱Netherlands johnv
@ghost of drupal past, can you explain the reasoning of your patch? Also, in my problem, I have theme hooks, not _alter() hooks.
Itis a wild guess, but Drupal 11.1 Adds Hooks as Classes mentions "In Drupal 11.1, the logic for calling a function based hook is now in ModuleHandler::legacyInvoke()".
So the introduction of that might be the culprit.
Anyway, this seems to be an error. - 🇨🇦Canada Charlie ChX Negyesi 🍁Canada
#17/#18 is a different issue as far as I can tell. I don't understand it but it's not the same issue, again, as far as I can see.
- 🇬🇧United Kingdom catch
Re #18 Office hours should be including its own file directly, it knows where it is, and does not need to go via the container at all.
- 🇳🇱Netherlands johnv
My #17/#18 was a response to #13, waiting for more (IIUC modules).
I think this problem is not module specific, since it is playing by the boom, until an upgrade to D11. 1 was performer. - 🇨🇦Canada Charlie ChX Negyesi 🍁Canada
To recap what's happened: the original hook OOP patch was a half year effort (including me travelling to Burgas on my own money solely to get it done but I digress) and obviously went through a lot of revisions. Including every module seemed necessary to get tests pass. As the patch shows, by the current revision it's no longer necessary and can be disaggregated into separate includes. We just never went through this effort because it didn't seem necessary -- but of course it is. This change is also beneficial in that it allows removing the separate includes in the future as each legacy mechanism bites the dust:
Thanks @nicxvan MR/patches mentioned in #12 did not provide a solution. They are also not ready to be applied.
- 🇺🇸United States nicxvan
I converted the patch to an MR. I could use some advice on the test, I tried a few different ways to trigger the failure before applying the patch, but nothing blew up. I added simple version of what I was doing for tests so people can check what I may be missing.
- 🇨🇦Canada Charlie ChX Negyesi 🍁Canada
No need to write a new test, just stick a Drupal::getContainer() call into any module used by a functional test, just to the top of the module. If it doesn't blow up then that's good enough, comment it's the test for this issue and to move it to another module should that one get deleted for any reason and call it a day.
- 🇺🇸United States nicxvan
Note, test only passes because the breaking change was introduced in config_test.module.
Not sure if this tag is appropriate, but someone needs to apply all the changes but the hook collector pass and module handler changes and confirm the test fails.
Core doesn't have any modules doing what contrib is doing so part of the test is introducing that pattern too.
- 🇺🇸United States nicxvan
I cleaned up, but I cannot get the test to fail, I created a new branch just to test it, but it is inconsistent.
Locally I could get it to fail if I installed the site and enabled config_test manually sometimes.
I could not get the test to fail. - 🇺🇸United States nicxvan
I had a theory, something is different with core functional tests. It fails as expected in normal functional tests.
Is it enough to leave a comment on the .module file or do we need a dedicated failing test?
- 🇺🇸United States smustgrave
Have not reviewed yet but issue summary needs some attention.
Thanks.
- 🇺🇸United States nicxvan
Ok I moved this to a new module and in a location where the test actually fails without the fix.
It seems there is something about functional tests in core not triggering this. I moved it to system, so this is ready for review.
I've updated the issue summary.
@jnicola, a minor request, when you create an issue, please leave all of the headings even if you do not need them at the moment, fill out the relevant ones. The other headings are needed and it saves someone needing to copy them over.
- 🇺🇸United States nicxvan
Ok for my own sanity:
git checkout 11.x Switched to branch '11.x' Your branch is up to date with 'origin/11.x'. nic@computer:/var/www/development/drupal$ ddev unit core/modules/system/tests/src/Functional/Hook/HookCollectorPassTest.php PHPUnit 10.5.38 by Sebastian Bergmann and contributors. Runtime: PHP 8.3.10 Configuration: /var/www/html/phpunit.xml F 1 / 1 (100%) Time: 00:08.124, Memory: 4.00 MB There was 1 failure: 1) Drupal\Tests\system\Functional\Hook\HookCollectorPassTest::testPreExistingConfigInstall Behat\Mink\Exception\ExpectationException: The string "Module <em class="placeholder">Container call outside function</em> has been installed." was not found anywhere in the HTML response of the current page. /var/www/html/vendor/behat/mink/src/WebAssert.php:888 /var/www/html/vendor/behat/mink/src/WebAssert.php:363 /var/www/html/core/tests/Drupal/Tests/WebAssert.php:558 /var/www/html/core/modules/system/tests/src/Functional/Hook/HookCollectorPassTest.php:55
You can see that fails the test on 11.x
I checkout this branch and revert the changes in HCP and module handler with git restore --source=b23f42703841a4632bce667dc58c16221d5e0998 core/lib
I confirmed that Drupal has the same code as HEAD
I run the test and it passes.Your branch is up to date with 'drupal-3505049/3505049-drupal-11.1.2-upgrade'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: core/lib/Drupal/Core/Extension/ModuleHandler.php modified: core/lib/Drupal/Core/Hook/HookCollectorPass.php Untracked files: (use "git add <file>..." to include in what will be committed) .gitignore no changes added to commit (use "git add" and/or "git commit -a") nic@weregiraffe:/var/www/development/drupal$ ddev unit core/modules/system/tests/src/Functional/Hook/HookCollectorPassTest.php PHPUnit 10.5.38 by Sebastian Bergmann and contributors. Runtime: PHP 8.3.10 Configuration: /var/www/html/phpunit.xml . 1 / 1 (100%) Time: 00:08.393, Memory: 4.00 MB OK (1 test, 6 assertions)
Any insight would be appreciated.
- 🇬🇧United Kingdom catch
It might be - try a ddev restart (or fpm etc. if not) or incrementing deployment_identifier?
- 🇺🇸United States nicxvan
I think I did run
ddev start
again, if it were a file cache wouldn't test only fail? - 🇨🇦Canada netgeek123
I ran into this issue just today when I updated from 10.4 to 11.1 as recommend. The Upgrade Status module gave the green light to update. Now, drush commands will not work. Tried all the usual things, clearing cache's etc.
I thought things were suppossed to become easier when updating Drupal? Now, there are several different roads to take, update to this version to get to that version that might work, even if a core supported module tells you it is good to go, it probably isn't , claims in documentation on how easy it is etc...
Well, it isn't easy what so ever. It is actually becoming increasingly diffcult to deal with. It is all fine when you're tinkering around. But, whe you have clients paying for this stuff it makes the developer look like an idiot. Not fun.
If things become worse I might just start recommending WIX!! haha!
drush updb -y
In Drupal.php line 169:
\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.
[townscanada@rockstar www]$ drush sqlq "TRUNCATE cache_config; TRUNCATE cache_container; TRUNCATE cache_data; TRUNCATE cache_default; TRUNCATE cache_discovery; TRUNCATE cache_dynamic_page_cache; TRUNCATE cache_entity; TRUNCATE cache_menu; TRUNCATE cache_render;"
[townscanada@rockstar www]$ drush cr
In Drupal.php line 169:
\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.
- 🇩🇪Germany Rudi Teschner
I've had the same problem happening during drush updb that resulted in custom modules with functional split up files to throw the error when loading files via Drupal::moduleHandler()->loadInclude().
https://git.drupalcode.org/project/drupal/-/merge_requests/11169.patch fixed it for me so that I don't get an error while using drush updb anymore.
- 🇺🇸United States smethawee
Hi Team @ nicxvan → , @ rudi teschner →
I still have no luck yet. Here for my issue, @ rudi teschner, how do you add the path to fix it? Any help, please. Thank you!
The website encountered an unexpected error. Try again later.
Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. in Drupal::getContainer() (line 169 of core/lib/Drupal.php).
Drupal::getContainer() (Line: 197)
Drupal::service() (Line: 101)
gin_lb_module_implements_alter() (Line: 94)
Drupal\Core\Hook\HookCollectorPass->process() (Line: 73)
Symfony\Component\DependencyInjection\Compiler\Compiler->compile() (Line: 814)
Symfony\Component\DependencyInjection\ContainerBuilder->compile() (Line: 1381)
Drupal\Core\DrupalKernel->compileContainer() (Line: 900)
Drupal\Core\DrupalKernel->initializeContainer() (Line: 505)
Drupal\Core\DrupalKernel->boot() (Line: 707)
Drupal\Core\DrupalKernel->handle() (Line: 19) - 🇩🇪Germany Rudi Teschner
@smethawee I've added the patch to drupal/core in my project's composer.patches.json file
"3505049 - Drupal 11.1.2 upgrade causes \\Drupal::$container is not initialized yet error": "https://git.drupalcode.org/project/drupal/-/merge_requests/11169.patch"and triggered drush cr afterwards. Result might be coincidence though since I didn't verify against a clean build.
The maintainers of the workflow module adressed this issue https://www.drupal.org/project/workflow/issues/3497950 🐛 \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. Active by changing the calls to loadInclude to require_once
- \Drupal::moduleHandler()->loadInclude('workflow', 'php', 'workflow.api'); + require_once __DIR__ . '/../../workflow.api.php';
- 🇺🇸United States smethawee
Hi @ rudi teschner → ,
Thank you for you to reply. This is the correct one on composer? I'm still no luck.
"drupal/tests": {
"3505049 - Drupal 11.1.2 upgrade causes \\Drupal::$container is not initialized yet error": "https://git.drupalcode.org/project/drupal/-/merge_requests/11169.patch"
} - 🇩🇪Germany Rudi Teschner
@smethawee
In my composer.patches.json its not drupal/tests but drupal/core since composer would not know that it has to patch core otherwise, does it?"drupal/core":{ "3505049 - Drupal 11.1.2 upgrade causes \\Drupal::$container is not initialized yet error": "https://git.drupalcode.org/project/drupal/-/merge_requests/11169.patch", },
Aside from that I fear I do not have any other useful suggestion
- 🇺🇸United States smethawee
@rudi teschner,
I so wondering about this. Thank you for you helped. But I still get the issue when run drush any command > drush updb or drush cr please below: - 🇺🇸United States nicxvan
Just to be clear, you should download the changes to a file and add that file to your repository in the patched directory.
You should not be using the MR diff directly for patching because anytime someone pushes a change your build will use the new change and you may not have tested it.
- 🇺🇸United States smethawee
@ nicxvan,
Thank you nicxvan!!! But I don't know which file I have to download from the changes to a file and add that file to my repository in the patched directory, Where I can find the patched directory?... /docroot/core/modules/system/tests/modules?
- 🇺🇸United States nicxvan
@smethawee, I don't want to derail this discussion too much more, but you should basically do what was mentioned in #50, but instead of putting the link https://git.drupalcode.org/project/drupal/-/merge_requests/11169.patch copy the content of that page into a file and reference it. Feel free to reach out on slack if you have more questions.
- 🇺🇸United States nicxvan
That test was a doozy, this is ready for review though.
Hi there,
can anyone say why it fails?patch -p1 -f < ../11169.patch
patching file core/modules/system/tests/modules/hook_collector_skip_procedural_attribute/hook_collector_skip_procedural_attribute.module
Hunk #1 succeeded at 12 with fuzz 2 (offset 3 lines).
The next patch would create the file core/tests/Drupal/FunctionalTests/Hook/HookCollectorPassTest.php,
which already exists! Applying it anyway.
patching file core/tests/Drupal/FunctionalTests/Hook/HookCollectorPassTest.php
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file core/tests/Drupal/FunctionalTests/Hook/HookCollectorPassTest.php.rej
patching file core/lib/Drupal/Core/Extension/ModuleHandler.php
Hunk #1 FAILED at 189.
1 out of 1 hunk FAILED -- saving rejects to file core/lib/Drupal/Core/Extension/ModuleHandler.php.rej
patching file core/lib/Drupal/Core/Hook/HookCollectorPass.php
Hunk #1 FAILED at 179.
Hunk #2 FAILED at 329.
2 out of 2 hunks FAILED -- saving rejects to file core/lib/Drupal/Core/Hook/HookCollectorPass.php.rej
The next patch would create the file core/modules/config/tests/config_test/config_test.module,
which already exists! Applying it anyway.
patching file core/modules/config/tests/config_test/config_test.module
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file core/modules/config/tests/config_test/config_test.module.rej
patching file core/tests/Drupal/FunctionalTests/Hook/HookCollectorPassTest.php
Hunk #1 FAILED at 14.
Hunk #2 FAILED at 24.
2 out of 2 hunks FAILED -- saving rejects to file core/tests/Drupal/FunctionalTests/Hook/HookCollectorPassTest.php.rej
patching file core/modules/config/tests/config_test/config_test.module
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file core/modules/config/tests/config_test/config_test.module.rej
patching file core/modules/config/tests/config_test/config_test.module
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file core/modules/config/tests/config_test/config_test.module.rej
patching file core/modules/system/tests/modules/hook_collector_skip_procedural_attribute/hook_collector_skip_procedural_attribute.module
Hunk #1 succeeded at 12 with fuzz 2 (offset 3 lines).
patching file core/tests/Drupal/FunctionalTests/Hook/HookCollectorPassTest.php
Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file core/tests/Drupal/FunctionalTests/Hook/HookCollectorPassTest.php.rej
patching file core/modules/system/tests/modules/container_no_function/container_no_function.info.yml
patching file core/modules/system/tests/modules/container_no_function/container_no_function.module (renamed from core/modules/config/tests/config_test/config_test.module)
patching file core/modules/system/tests/src/Functional/Hook/HookCollectorPassTest.php (renamed from core/tests/Drupal/FunctionalTests/Hook/HookCollectorPassTest.php)
Cannot rename file without two valid file names- 🇮🇳India Raveen Kumar
Hello Guys,
I am running into an issue, While upgrading my Drupal Website from Drupal 10.4 to Drupal 11, I am running into an issue.
I am attaching the screenshot of issue, This occurs when i runs upgrade command.
It would be really appreciated if I can get some help over here.
And Thank You. - 🇦🇹Austria reinimax
I ran into this issue when I upgraded from 11.1.4 to 11.1.5. I created a patch from the MR and it applied, but I still get the error.
- 🇮🇳India Raveen Kumar
"require": {
"php": ">=7.4",
"civicrm/civicrm-asset-plugin": "~1.1",
"civicrm/civicrm-core": "^5.78",
"civicrm/civicrm-drupal-8": "^5.80",
"civicrm/civicrm-packages": "^5.80",
"civicrm/cli-tools": "^2024.09",
"composer/installers": "^1.9",
"cweagans/composer-patches": "^1.7",
"drupal/admin_toolbar": "^3.5",
"drupal/antibot": "^2.0",
"drupal/auto_translation": "^1.3",
"drupal/better_exposed_filters": "^7.0",
"drupal/book": "^2.0",
"drupal/calendar": "^1.0@beta",
"drupal/calendar_view": "^2.1",
"drupal/civicrm_drush": "^4.0@beta",
"drupal/civicrm_entity": "4.0.x-dev@dev",
"drupal/civicrm_entity_leaflet-civicrm_entity_leaflet": "^2.0@alpha",
"drupal/civicrm_reroute_mail": "^1.0",
"drupal/color": "^1.0",
"drupal/config_update": "^2.0@alpha",
"drupal/core": "11.0.12",
"drupal/core-composer-scaffold": "^11.0.12",
"drupal/core-recommended": "^11.0.12",
"drupal/drupal_slider": "^2.1",
"drupal/entity": "^1.5",
"drupal/entity_reference_revisions": "^1.12",
"drupal/features": "^5.0@alpha",
"drupal/forum": "^1.0",
"drupal/geocoder": "^4.26",
"drupal/geolocation": "^3.10",
"drupal/gin": "^4.0",
"drupal/gin_toolbar": "^2.0",
"drupal/hierarchical_taxonomy_menu": "^2.0",
"drupal/honeypot": "^2.2",
"drupal/imce": "^3.1",
"drupal/inline_entity_form": "^3.0@RC",
"drupal/jwt": "^2.2",
"drupal/leaflet": "^10.2",
"drupal/leaflet_more_maps": "^2.2",
"drupal/legal": "^4.0@alpha",
"drupal/mailchimp": "^3.0",
"drupal/maillog": "^1.1",
"drupal/mailsystem": "^4.5",
"drupal/masquerade": "^2.0",
"drupal/metatag": "^2.1",
"drupal/migrate_plus": "^6.0",
"drupal/migrate_upgrade": "^4.0",
"drupal/mimemail": "^1.0@alpha",
"drupal/passwordless": "2.0.x-dev@dev",
"drupal/pathauto": "^1.13",
"drupal/phpmailer_smtp": "2.2.x-dev@dev",
"drupal/profile": "^1.11",
"drupal/rdf": "^3.0@beta",
"drupal/recaptcha_v3": "^2.0",
"drupal/reroute_email": "^2.3@RC",
"drupal/slick": "^3.0",
"drupal/slick_views": "^3.0",
"drupal/smart_ip": "^5.0@alpha",
"drupal/smtp": "^1.0",
"drupal/state_machine": "^1.12",
"drupal/superfish": "^1.6",
"drupal/tiny_slider": "^1.1@RC",
"drupal/token": "^1.15",
"drupal/twig_tweak": "^3.3",
"drupal/upgrade_status": "^4.3",
"drupal/views_infinite_scroll": "^2.0",
"drupal/views_migration": "^1.2",
"drupal/views_slideshow": "^5.0",
"drupal/views_templates": "^1.2",
"drupal/webform": "^6.3@alpha",
"drupal/webform_civicrm": "^6.2",
"drupal/webform_migrate": "^2.0@alpha",
"drush/drush": "^13",
"mglaman/composer-drupal-lenient": "^1.0",
"phpoffice/phpword": "^1.2",
"vlucas/phpdotenv": "^5.1",
"webflo/drupal-finder": "^1.2",
"wikimedia/composer-merge-plugin": "^2.1"
}, - 🇦🇹Austria reinimax
Here are my modules:
"require": { "composer/installers": "^2.3", "drupal/admin_toolbar": "^3.5", "drupal/better_exposed_filters": "^7.0", "drupal/coffee": "^2.0", "drupal/config_split": "^2.0", "drupal/core-composer-scaffold": "^11.1", "drupal/core-project-message": "^11.1", "drupal/core-recommended": "^11.1", "drupal/easy_breadcrumb": "^2.0", "drupal/field_group": "^3.6", "drupal/focal_point": "^2.1", "drupal/gin": "^3.0", "drupal/gin_lb": "^1.0@RC", "drupal/gin_login": "^2.1", "drupal/honeypot": "^2.2", "drupal/inline_block_title_automatic": "^2.0", "drupal/layout_builder_browser": "^1.8", "drupal/layout_builder_modal": "^2.0", "drupal/layout_builder_operation_link": "^2.2", "drupal/metatag": "^2.1", "drupal/pathauto": "^1.13", "drupal/preprocess": "^2.2", "drupal/redirect": "^1.11", "drupal/sam": "^1.3", "drupal/shield": "^1.8", "drupal/simple_sitemap": "^4.2", "drupal/twig_tweak": "^3.4", "drupal/ultimate_cron": "^2.0@beta", "drupal/webform": "^6.3@beta", "drush/drush": "^13.3", "vlucas/phpdotenv": "^5.6", "wikimedia/composer-merge-plugin": "^2.1" }, "require-dev": { "drupal/coder": "^8.3", "drupal/core-dev": "^11", "drupal/masquerade": "^2.0", "drupal/webprofiler": "^11.1", "phpstan/extension-installer": "^1.4" }
- 🇮🇳India Raveen Kumar
Hello I have applied the patch but issue still persist for me.
My current website is in Drupal version - 11.0.13Once I hit upgrade to 11.1.2 version. I am getting issue.
Then I applied the patch, The patch applied successfully. But issue still persists and site goes down.I am adding screenshots and patch which I have used.
And Thank You
- 🇦🇹Austria reinimax
@nicxvan I tried both patches #19 and #23 as well as the diff from the merge request. They applied, but I still get the container is not initialized yet error.
If this helps, the site was created with Drupal 11.1.4 and on this version I have no problems. The error occurs when doing a
drush cr
immediately after the updating to 11.1.5. Since @raveen_thakur51 has the same problem when updating to 11.1.2, maybe the issue has something to do with updating core itself? - Status changed to Needs review
about 1 month ago 11:55am 8 April 2025 - 🇦🇹Austria reinimax
Update: for me, the culprit was the gin_lb module. Applying the patch from this issue 🐛 \Drupal::$container is not initialized yet Active solved my problem.
I'm also getting this error when updating from 11.0.8 to 11.1.5 or 11.1.6. Specifically the error I get is:
In Drupal.php line 169:
\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.
I'm also getting this error when updating to 11.1.6.
The patch 111669.diff can't be used to resolve this error when updating to 11.1.6, because the directory structure and contents of core directory are different from 11.1.2.
So, if we are trying to update Drupal to 11.1.6, how would you recommend that be done? I've tried using the standard composer update process (composer update "drupal/core-*" --with-all-dependencies) from 11.0.8 to 11.1.6, but it fails every time with the "\Drupal::$container is not initialized yet error". Since you are saying the patch can't be used to resolve this error due to different directory structure and core contents how do we circumvent that? Thanks for any assistance.
- 🇺🇸United States nicxvan
Sharing the modules you have installed is a good first step, we need to identify the cause so we can fix it properly.
- 🇬🇧United Kingdom catch
I've tried using the standard composer update process (composer update "drupal/core-*" --with-all-dependencies) from 11.0.8 to 11.1.6, but it fails every time with the "\Drupal::$container is not initialized yet error"
Are you getting that error from
composer update
itself? Or from the Drupal site after you composer update?composer update shouldn't be bootstrapping Drupal, unless there is a weird composer plugin involved or something.
you should be able to apply the patch to 11.1.6 using composer patches.
The Needs Review Queue Bot → tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
- 🇺🇸United States sher1
This is just weird. I used composer to update from 11.1.6 to 11.1.7. It resulted in the white screen error and drush stopped working. Started getting the container does not exist error. I added cweagans/composer-patches and added this patch
"patches": { "drupal/core": { "patch-name": "https://www.drupal.org/files/issues/2025-02-08/3505049_23.patch" } }
Then I realized that there were a number of people claiming that gin was related so even though it wasn't enabled, I removed gin and the gin_toolbar. Just to make sure that was the problem, I removed the patch and re-ran the composer update -W. It removed the patched core and put down a fresh one. And there was no more error. I currently don't have the patch in place but it is still working fine, drush included.
This is my package list:
asm89/stack-cors v2.2.0 Cross-origin resource sharing library and stack middleware
aws/aws-crt-php v1.2.7 AWS Common Runtime for PHP
aws/aws-sdk-php 3.343.10 AWS SDK for PHP - Use Amazon Web Services in your PHP project
caxy/php-htmldiff v0.1.16 A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.
chi-teck/drupal-code-generator 4.1.0 Drupal code generator
composer/installers v2.3.0 A multi-framework Composer library installer
composer/semver 3.4.3 Semver library that offers utilities, version constraint parsing and validation.
consolidation/annotated-command 4.10.1 Initialize Symfony Console commands from annotated command class methods.
consolidation/config 3.1.0 Provide configuration services for a commandline tool.
consolidation/filter-via-dot-access-data 2.0.2 This project uses dflydev/dot-access-data to provide simple output filtering for applications built with annotated-command / Robo.
consolidation/log 3.1.0 Improved Psr-3 / Psr\Log logger based on Symfony Console components.
consolidation/output-formatters 4.6.0 Format text by applying transformations provided by plug-in formatters.
consolidation/robo 5.1.0 Modern task runner
consolidation/site-alias 4.1.1 Manage alias records for local and remote sites.
consolidation/site-process 5.4.2 A thin wrapper around the Symfony Process Component that allows applications to use the Site Alias library to specify the target for a remote call.
cweagans/composer-patches 1.7.3 Provides a way to patch Composer packages.
dflydev/dot-access-data v3.0.3 Given a deep data structure, access data by dot notation.
doctrine/annotations 2.0.2 Docblock Annotations Parser
doctrine/collections 2.3.0 PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common 3.5.0 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, proxies and much more.
doctrine/deprecations 1.1.5 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.
doctrine/event-manager 2.0.1 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/lexer 2.1.1 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/persistence 4.0.0 The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
dragonmantank/cron-expression v3.4.0 CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
drupal/admin_toolbar 3.5.3 Provides a drop-down menu interface to the core Drupal Toolbar.
drupal/advban 1.8.0 Advanced banning of IP addresses.
drupal/autoban 1.11.0 Automatic IP ban using dblog table.
drupal/bootstrap5_admin 1.1.35 Admin Bootstrap 5, faster and easier web application development.
drupal/bpmn_io 2.0.8 BPMN modeller for ECA, integrated into Drupal's admin UI.
drupal/ckeditor5_plugin_pack 1.3.1 The plugin pack for the CKEditor 5 WYSIWYG editor.
drupal/ckeditor5_premium_features 1.4.1 The premium features for the CKEditor 5 WYSIWYG editor.
drupal/config_update 2.0.0-alpha4 Provides basic revert and update functionality for other modules.
drupal/core 11.1.7 Drupal is an open source content management platform powering millions of websites and applications.
drupal/core-composer-scaffold 11.1.7 A flexible Composer project scaffold builder.
drupal/core-project-message 11.1.7 Adds a message after Composer installation.
drupal/core-recommended 11.1.7 Core and its dependencies with known-compatible minor versions. Require this project INSTEAD OF drupal/core.
drupal/crop 2.4.0 Provides storage and API for image crops.
drupal/ctools 4.1.0 Provides a number of utility and helper APIs for Drupal developers and site builders.
drupal/devel 5.3.1 Various blocks, pages, and functions for developers.
drupal/easy_email 3.0.4 Easy Email is an HTML email system for Drupal, designed to be as simple as possible to configure, with a robust set of features.
drupal/eca 2.1.7 Event, Conditions, Actions - powerful, versatile, and user-friendly rules engine for Drupal
drupal/eca_modeller_bpmn 2.1.7 Common functionality for all BPMN based modeller implementations.
drupal/eca_ui 2.1.7 Provides a user interface for managing ECA models.
drupal/eca_webform 2.0.1 Integrate ECA with the Webform module and its plugins.
drupal/entity 1.6.0 Provides expanded entity APIs, which will be moved to Drupal core one day.
drupal/flexible_permissions 2.0.1 This module allows you to gather, calculate and cache permissions from a myriad of sources
drupal/flood_control 3.0.0 Provides administration possibilities for hidden flood control variables
drupal/focal_point 2.1.2 Focal Point allows content creators to mark the most important part of an image for easier cropping.
drupal/group 3.3.5 This module allows you to group users, content and other entities
drupal/imce 3.1.3 Provides a file manager supporting personal folders.
drupal/jquery_ui 1.7.0 Provides jQuery UI library.
drupal/jquery_ui_autocomplete 2.1.0 Provides jQuery UI Autocomplete library.
drupal/jquery_ui_menu 2.1.0 Provides jQuery UI Menu library.
drupal/jquery_ui_resizable 2.1.0 Provides jQuery UI Resizable library.
drupal/kint-kint 2.0.0 Kint dumping tool, drupal-specific kint configs, and devel integration
drupal/mailsystem 4.5.0 Mail System
drupal/media_library_edit 3.0.4 Add an edit button to the Media Library widget when an item is selected.
drupal/memory_profiler_plus 1.0.0 A module for recording request profiling memory usage in the database.
drupal/menu_bootstrap_icon 1.0.15 This module provides menu icon bootstrap 5
drupal/module_filter 5.0.3 Filter the modules list.
drupal/pathauto 1.13.0 Provides a mechanism for modules to automatically generate aliases for the content they manage.
drupal/radix 6.0.2 Radix is a Bootstrap 5 component-based base theme for Drupal. It has Bootstrap, Sass, BrowserSync and a lot more goodies built-in.
drupal/redirect 1.11.0 Allows users to redirect from old URLs to new URLs.
drupal/scheduler 2.2.1 Automatically publish and unpublish content at specified dates and times.
drupal/schema_ui 1.2.1 Provides a user interface for entity field schema.
drupal/seckit 2.0.3 SecKit provides Drupal with various security-hardening options.
drupal/smart_date 4.2.3 Adds app-like date and recurring date functionality.
drupal/symfony_mailer_lite 2.0.2 Drupal Symfony Mailer Lite
drupal/time_field 2.1.3 Provides 'Time Field' and 'Time Range Field'.
drupal/token 1.15.0 Provides a user interface for the Token API, some missing core tokens.
drupal/tracer 1.2.0 Tracer API replaces some of the Core's services with a traceable version.
drupal/webform 6.3.0-beta2 Enables the creation of webforms and questionnaires.
drupal/webform_views 5.5.0 Webform integration with views.
drupal/webprofiler 11.1.0 Extract, collect, store and display profiling information for Drupal.
drush/drush 13.6.0 Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hack...
egulias/email-validator 4.0.4 A library for validating emails against several RFCs
erusev/parsedown 1.7.4 Parser for Markdown.
ezyang/htmlpurifier v4.18.0 Standards compliant HTML filter written in PHP
firebase/php-jwt v6.11.1 A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
grasmash/expander 3.0.1 Expands internal property references in PHP arrays file.
grasmash/yaml-cli 3.2.1 A command line tool for reading and manipulating yaml files.
guzzlehttp/guzzle 7.9.3 Guzzle is a PHP HTTP client library
guzzlehttp/promises 2.0.4 Guzzle promises library
guzzlehttp/psr7 2.7.1 PSR-7 message implementation that also provides common utility methods
html2text/html2text 4.3.2 Converts HTML to formatted plain text
kint-php/kint 6.0.1 Kint - Advanced PHP dumper
kint-php/kint-twig 6.0 Twig extension for Kint integration
laravel/prompts v0.3.5 Add beautiful and user-friendly forms to your command-line applications.
league/commonmark 2.7.0 Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)
league/config v1.2.0 Define configuration arrays with strict schemas and access values with dot notation
league/container 4.2.4 A fast and intuitive dependency injection container.
masterminds/html5 2.9.0 An HTML5 parser and serializer.
mck89/peast v1.16.3 Peast is PHP library that generates AST for JavaScript code
mtdowling/jmespath.php 2.8.0 Declaratively specify how to extract elements from a JSON document
mtownsend/xml-to-array 2.0.0 Easily convert valid xml to a php array.
nette/schema v1.3.2 📐 Nette Schema: validating data structures against a given Schema.
nette/utils v4.0.6 🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
nikic/php-parser v5.4.0 A PHP parser written in PHP
openai-php/client v0.10.3 OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API
pear/archive_tar 1.5.0 Tar file management class with compression support (gzip, bzip2, lzma2)
pear/console_getopt v1.4.3 More info available on: http://pear.php.net/package/Console_Getopt
pear/pear-core-minimal v1.10.16 Minimal set of PEAR core files to be used as composer dependency
pear/pear_exception v1.0.2 The PEAR Exception base class.
phootwork/collection v3.2.3 The phootwork library fills gaps in the php language and provides better solutions than the existing ones php offers.
phootwork/lang v3.2.3 Missing PHP language constructs
php-http/discovery 1.20.0 Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations
php-http/multipart-stream-builder 1.4.2 A builder class that help you create a multipart stream
php-tuf/composer-stager v2.0.1 Stages Composer commands so they can be safely run on a production codebase.
phpowermove/docblock v4.0 PHP Docblock parser and generator. An API to read and write Docblocks.
psr/cache 3.0.0 Common interface for caching libraries
psr/container 2.0.2 Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher 1.0.0 Standard interfaces for event handling.
psr/http-client 1.0.3 Common interface for HTTP clients
psr/http-factory 1.1.0 PSR-17: Common interfaces for PSR-7 HTTP message factories
psr/http-message 2.0 Common interface for HTTP messages
psr/log 3.0.2 Common interface for logging libraries
psy/psysh v0.12.8 An interactive shell for modern PHP.
ralouphie/getallheaders 3.0.3 A polyfill for getallheaders.
revolt/event-loop v1.0.7 Rock-solid event loop for concurrent PHP applications.
scrivo/highlight.php v9.18.1.10 Server side syntax highlighter that supports 185 languages. It's a PHP port of highlight.js
sebastian/diff 5.1.1 Diff implementation
simshaun/recurr v5.0.3 PHP library for working with recurrence rules
symfony/console v7.2.6 Eases the creation of beautiful and testable command line interfaces
symfony/css-selector v7.2.0 Converts CSS selectors to XPath expressions
symfony/dependency-injection v7.2.6 Allows you to standardize and centralize the way objects are constructed in your application
symfony/deprecation-contracts v3.5.1 A generic function and convention to trigger deprecation notices
symfony/error-handler v7.2.5 Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher v7.2.0 Provides tools that allow your application components to communicate with each other by dispatching events and listening to them
symfony/event-dispatcher-contracts v3.5.1 Generic abstractions related to dispatching event
symfony/filesystem v7.2.0 Provides basic utilities for the filesystem
symfony/finder v7.2.2 Finds files and directories via an intuitive fluent interface
symfony/http-foundation v7.2.6 Defines an object-oriented layer for the HTTP specification
symfony/http-kernel v7.2.6 Provides a structured process for converting a Request into a Response
symfony/mailer v7.2.6 Helps sending emails
symfony/mime v7.2.6 Allows manipulating MIME messages
symfony/polyfill-ctype v1.31.0 Symfony polyfill for ctype functions
symfony/polyfill-iconv v1.31.0 Symfony polyfill for the Iconv extension
symfony/polyfill-intl-grapheme v1.31.0 Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-idn v1.31.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer v1.31.0 Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring v1.31.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php80 v1.32.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81 v1.32.0 Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/polyfill-php83 v1.32.0 Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions
symfony/polyfill-php84 v1.32.0 Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions
symfony/process v7.2.5 Executes commands in sub-processes
symfony/psr-http-message-bridge v7.2.0 PSR HTTP message bridge
symfony/routing v7.2.3 Maps an HTTP request to a set of configuration variables
symfony/serializer v7.2.6 Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.
symfony/service-contracts v3.5.1 Generic abstractions related to writing services
symfony/stopwatch v7.2.4 Provides a way to profile code
symfony/string v7.2.6 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way
symfony/translation-contracts v3.5.1 Generic abstractions related to translation
symfony/validator v7.2.6 Provides tools to validate values
symfony/var-dumper v7.2.6 Provides mechanisms for walking through any arbitrary PHP variable
symfony/var-exporter v7.2.6 Allows exporting any serializable PHP data structure to plain PHP code
symfony/yaml v7.2.6 Loads and dumps YAML files
tijsverkoyen/css-to-inline-styles v2.3.0 CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.
twig/twig v3.19.0 Twig, the flexible, fast, and secure template language for PHP
webmozart/assert 1.11.0 Assertions to validate method input/output with nice error messages. - 🇨🇦Canada Charlie ChX Negyesi 🍁Canada
@sher1 thanks for you report, could you edit your comment and attach the list as a text file please? The issue is becoming very long with these super long comments.
- 🇺🇸United States sher1
Gin was 4.0.6 and gin toolbar was 2.0.0. They were both present but uninstalled when I applied the first patch.
- 🇺🇸United States nicxvan
Thank you sher1!
I'm beginning to think this has nothing to do with the specific module(s) directly but something changing with drupal, this happened in a db import and a drupal update and composer.
Both the module and theme are the latest and have the problematic code modified.
Maybe something happens to the container in those processes and it fails to build?
There shouldn't be something between 11.1.6 and 11.1.7, maybe we can check that diff and see if something was introduced?
- 🇺🇸United States sher1
I should mention that the same error happened from 11.1.5 to 11.1.6 but I didn't have any real content on the site so I just deleted and installed new. I had time today so I looked more into the issues queue. I am happy to test out anything you come across
- 🇺🇸United States sher1
I just did a vanilla Umami install of 11.1.5 from drupal/recommended-project, didn't add any new modules or code except drush. Did a composer update -W to 11.1.7 and everything came through fine, no errors.
- 🇪🇸Spain julian_esimaginacion
The patch https://www.drupal.org/files/issues/2025-02-08/3505049_23.patch → Works in 11.1.7 for me