symfony: Failed to generate ConfigBuilder for extension
Symfony version(s) affected
5.3.12
Description
When clearing cache or warming up cache I get the following warning messages in the cli.
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Sensio\Bundle\FrameworkExtraBundle\DependencyInjection\SensioFrameworkExtraExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Sensio\Bundle\FrameworkExtraBundle\DependencyInjection\SensioFrameworkExtraExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Doctrine\Bundle\MigrationsBundle\DependencyInjection\DoctrineMigrationsExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Doctrine\Bundle\MigrationsBundle\DependencyInjection\DoctrineMigrationsExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Twig\Extra\TwigExtraBundle\DependencyInjection\TwigExtraExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Twig\Extra\TwigExtraBundle\DependencyInjection\TwigExtraExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Symfony\Bundle\WebProfilerBundle\DependencyInjection\WebProfilerExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Symfony\Bundle\WebProfilerBundle\DependencyInjection\WebProfilerExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Symfony\Bundle\DebugBundle\DependencyInjection\DebugExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Symfony\Bundle\DebugBundle\DependencyInjection\DebugExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Symfony\Bundle\MakerBundle\DependencyInjection\MakerExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Symfony\Bundle\MakerBundle\DependencyInjection\MakerExtension"]
15:16:56 WARNING [app] Failed to generate ConfigBuilder for extension Symfony\Bundle\SwiftmailerBundle\DependencyInjection\SwiftmailerExtension. ["exception" => Symfony\Component\DependencyInjection\Exception\EnvNotFoundException^ { …},"extensionClass" => "Symfony\Bundle\SwiftmailerBundle\DependencyInjection\SwiftmailerExtension"]
How to reproduce
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-openssl": "^7.2",
"authorizenet/authorizenet": "^2.0",
"composer/package-versions-deprecated": "1.11.99.2",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "^2.9",
"fpdf/fpdf": "^1.83",
"google/apiclient": "^2.0",
"iivanov/hotel-api-sdk-php": "^3.0",
"league/flysystem": "^2.3",
"paypal/paypal-checkout-sdk": "^1.0",
"phpdocumentor/reflection-docblock": "^5.2",
"phpoffice/phpspreadsheet": "^1.18",
"rollerworks/password-strength-validator": "^1.4",
"sensio/framework-extra-bundle": "^6.1",
"stripe/stripe-php": "^7.98",
"symfony/apache-pack": "^1.0",
"symfony/asset": "5.3.*",
"symfony/browser-kit": "5.3.*",
"symfony/console": "5.3.*",
"symfony/dotenv": "5.3.*",
"symfony/expression-language": "5.3.*",
"symfony/flex": "^1.3.1",
"symfony/form": "5.3.*",
"symfony/framework-bundle": "5.3.*",
"symfony/http-client": "5.3.*",
"symfony/intl": "5.3.*",
"symfony/mailer": "5.3.*",
"symfony/messenger": "5.3.*",
"symfony/mime": "5.3.*",
"symfony/monolog-bundle": "^3.1",
"symfony/notifier": "5.3.*",
"symfony/process": "5.3.*",
"symfony/property-access": "5.3.*",
"symfony/property-info": "5.3.*",
"symfony/proxy-manager-bridge": "5.3.*",
"symfony/runtime": "5.3.*",
"symfony/security-bundle": "5.3.*",
"symfony/serializer": "5.3.*",
"symfony/string": "5.3.*",
"symfony/swiftmailer-bundle": "^3.5",
"symfony/translation": "5.3.*",
"symfony/twig-bundle": "^5.3",
"symfony/validator": "5.3.*",
"symfony/web-link": "5.3.*",
"symfony/yaml": "5.3.*",
"twig/cssinliner-extra": "^3.3",
"twig/extra-bundle": "^3.3",
"twig/intl-extra": "^3.3",
"twig/twig": "^2.12|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"symfony/css-selector": "^5.3",
"symfony/debug-bundle": "^5.3",
"symfony/maker-bundle": "^1.0",
"symfony/phpunit-bridge": "^5.3",
"symfony/stopwatch": "^5.3",
"symfony/var-dumper": "^5.3",
"symfony/web-profiler-bundle": "^5.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.3.*"
}
}
}
Possible Solution
I attached my composer.json so you could look at the packages that I have installed to see if they are what may be cauing this issue.
Additional Context
As far as we can tell no operational impact at this time, but we are concerned that it may have an impact in the future as we migrate to a newer version of Symfony.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 20 (7 by maintainers)
Commits related to this issue
- Print the original exception message Fixes #45614 — committed to Tofandel/symfony by Tofandel 2 years ago
- minor #48197 [FrameworkBundle] Print the original exception message (Tofandel) This PR was squashed before being merged into the 6.2 branch. Discussion ---------- [FrameworkBundle] Print the origin... — committed to symfony/symfony by nicolas-grekas 2 years ago
Had tons of
Failed to generate ConfigBuilder for extension
Found this phrase at
ConfigBuilderCacheWarmer
After commenting out exception catching like this:
and running
bin/console cache:warmup
I’ve got true the reason:So, to fix annoying
Failed to generate ConfigBuilder for extension
messages I had to just add accidentally missedBLA_BLA_BLA=
to.env
I literally just logged in just to say thank you!
I had a very similar problem and was getting
Failed to generate ConfigBuilder for extension
errors when running certainbin/console
commands. After spending several hours tracing through my code and Symfony code in an attempt to find the issue, I finally solved it by updating thebin/console
file (I copied it from a recent fresh install of Symfony 5.4).The site with this problem was originally created on Symfony 4 and had been updated to Symfony 5. While all the packages were updated, the actual
bin/console
file was still the original version. The oldbin/console
command handles the loading of.env
variables differently than more recent versions and this was the cause of the error messages.I was expecting the
bin/console
command to be automatically updated when thesymfony/console
package is updated, but apparently that is not how it works.Same issue here. For me it was in an upgraded SF4 LTS to SF5 LTS project:
Environment variable not found: "APP_SECRET".
Upgrading bin/console to use the new runtime component did not fix anything here, but still is a good idea.
Thanks to @igormukhingmailcom for the simple idea! The exception message should include the original exception message. See CacheWarmer/ConfigBuilderCacheWarmer.php around line 59.
Simply add
$e->getMessage()
to the log message to find the real reason:I find it weird that I have to supply all environment variables upon build time to not get warnings. Env-vars are supposed to be runtime vars.
So if I have to set all env parameters to empty defaults, what’s the point of this warning? What is it warning me of? I still don’t get a warning if I forget to set the env var on the production server at runtime.
Hi, once I got this problem because in my services.yaml I had some parameters that wasnt on my .env files . Check that!
Can we replace the log to
$this->logger?->warning('Failed to generate ConfigBuilder for extension {extensionClass}.', ['exception' => $e->getMessage(), 'extensionClass' => \get_class($extension)]);
Currently the exception message is not visible
The
Failed to generate ConfigBuilder for extension
log warning includes the exception in the context, so you should have access to the exception message in your logs though.HI, I have the same problem and i can’t use php bin/console make:migration or symfony console make:migration i have an error who said Command “make:migration” is not defined.