Skip to content

The service "serializer.normalizer.translatable" has a dependency on a non-existent service "translator" #52847

@greg0ire

Description

@greg0ire

Symfony version(s) affected

6.4.0

Description

After upgrading an application that has the translator disabled from 6.3 to 6.4, I'm getting the following error when running any command:


In CheckExceptionOnInvalidReferenceBehaviorPass.php line 88:

  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
  The service "serializer.normalizer.translatable" has a dependency on a non-existent service "translator".


Exception trace:
  at /app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:88
 Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:90
 Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:51
 Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:99
 Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:51
 Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:90
 Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:51
 Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:48
 Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->process() at /app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:42
 Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->process() at /app/vendor/symfony/dependency-injection/Compiler/Compiler.php:80
 Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /app/vendor/symfony/dependency-injection/ContainerBuilder.php:767
 Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /app/vendor/symfony/http-kernel/Kernel.php:506
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /app/vendor/symfony/http-kernel/Kernel.php:763
 Symfony\Component\HttpKernel\Kernel->preBoot() at /app/vendor/symfony/http-kernel/Kernel.php:126
 Symfony\Component\HttpKernel\Kernel->boot() at /app/vendor/symfony/framework-bundle/Console/Application.php:190
 Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() at /app/vendor/symfony/framework-bundle/Console/Application.php:72
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at /app/bin/console:49

How to reproduce

# config/packages/framework.yaml

framework:
    translator:
        enabled: false

Possible Solution

Add a check here:

if (!class_exists(Translator::class)) {
$container->removeDefinition('serializer.normalizer.translatable');
}
? This will probably require passing the translator configuration to the method where that check resides.

Additional Context

Switching enabled to true fixes the issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions