symfony/symfony · error · RuntimeException

This command does not support the application kernel: "%s" d

Error message

This command does not support the application kernel: "%s" does not extend "%s".

What it means

Thrown by `lint:container` when the application kernel does not extend `Symfony\Component\HttpKernel\Kernel` AND the cached debug container dump is missing or stale. The command needs to rebuild the container from the kernel, which requires reflective access to the protected `initializeBundles()` and `buildContainer()` methods that only exist on the base `Kernel` class.

Source

Thrown at src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php:86

        $io->success('The container was linted successfully: all services are injected with values that are compatible with their type declarations.');

        return 0;
    }

    private function getContainerBuilder(bool $resolveEnvVars): ContainerBuilder
    {
        if (isset($this->container)) {
            return $this->container;
        }

        $kernel = $this->getApplication()->getKernel();
        $container = $kernel->getContainer();
        $file = $kernel->isDebug() ? $container->getParameter('debug.container.dump') : false;

        if (!$file || !(new ConfigCache($file, true))->isFresh()) {
            if (!$kernel instanceof Kernel) {
                throw new RuntimeException(\sprintf('This command does not support the application kernel: "%s" does not extend "%s".', get_debug_type($kernel), Kernel::class));
            }

            $buildContainer = \Closure::bind(function (): ContainerBuilder {
                $this->initializeBundles();

                return $this->buildContainer();
            }, $kernel, $kernel::class);
            $container = $buildContainer();
        } else {
            $container = unserialize(file_get_contents(substr_replace($file, '.ser', -4)), ['allowed_classes' => true]);

            if (!$container instanceof ContainerBuilder) {
                throw new RuntimeException(\sprintf('This command does not support the application container: "%s" is not a "%s".', get_debug_type($container), ContainerBuilder::class));
            }

            if ($resolveEnvVars) {
                $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveParameterPlaceHoldersPass(), new ResolveFactoryClassPass()]);
            } else {

View on GitHub (pinned to 698e28026c)

Solutions

  1. Make your application kernel extend `Symfony\Component\HttpKernel\Kernel` instead of only implementing `KernelInterface`.
  2. Warm the cache first (`php bin/console cache:warmup`) so the debug container dump exists and is fresh.
  3. If a custom kernel is intentional and cannot extend `Kernel`, accept that `lint:container` is unsupported in that setup.

Example fix

// before
class MicroKernel implements KernelInterface { ... }

// after
class MicroKernel extends \Symfony\Component\HttpKernel\Kernel
{
    // registerBundles(), registerContainerConfiguration() ...
}
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the kernel extends the base Kernel before relying on lint:container.
if (!($kernel instanceof \Symfony\Component\HttpKernel\Kernel)) {
    // lint:container is unsupported; skip or warm cache first
}

Type guard

function kernelSupportsLint(\Symfony\Component\HttpKernel\KernelInterface $kernel): bool
{
    return $kernel instanceof \Symfony\Component\HttpKernel\Kernel;
}

Try / catch

try {
    $exit = $command->run($input, $output);
} catch (\Symfony\Component\Console\Exception\RuntimeException $e) {
    // kernel unsupported; fall back to cache:warmup or skip linting
}

Prevention

When it happens

Trigger: Running `php bin/console lint:container` with a custom kernel class that implements `KernelInterface` directly (instead of extending `Kernel`), when the debug container dump file referenced by the `debug.container.dump` parameter is absent or not fresh.

Common situations: Custom micro-framework kernels, test fixtures with minimal kernel implementations, or bootstraps that replaced the standard Kernel with a lighter alternative. Also seen when the cache has been cleared in debug mode but not regenerated.

Related errors


AI-assisted analysis of symfony/symfony@698e28026c (2026-08-06). Data as JSON: /api/errors/ccbdcac9c84bfbdf. Report an issue: GitHub.