Service autowiring depends on symfony/config that is missing from composer (at least dev)

Created on 5 January 2023, almost 2 years ago
Updated 1 February 2023, almost 2 years ago

Problem/Motivation

Playing around with service autowiring, I incurrred into

PHPUnit 9.5.26 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\file_mdm_exif\Kernel\FileMetadataExifTest
ERE                                                                 3 / 3 (100%)E

Time: 00:01.383, Memory: 4.00 MB

There were 3 errors:

1) Drupal\Tests\file_mdm_exif\Kernel\FileMetadataExifTest::testExifPlugin
Error: Class "Symfony\Component\Config\Resource\ClassExistenceResource" not found

/var/www/html/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:526
/var/www/html/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:505
[...]

This happens when autowiring cannot determine a unique service to be injected as an argument. Which is an error, yes, but the error reported here is that symfony/config is missing as a dependency (at least a dev one).

If I add the package to my codebase, I end up with a much better understandable error:

PHPUnit 9.5.26 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\file_mdm_exif\Kernel\FileMetadataExifTest
ERE                                                                 3 / 3 (100%)E

Time: 00:02.070, Memory: 4.00 MB

There were 3 errors:

1) Drupal\Tests\file_mdm_exif\Kernel\FileMetadataExifTest::testExifPlugin
Symfony\Component\DependencyInjection\Exception\RuntimeException: Cannot autowire service "file_metadata_manager": argument "$logger" of method "Drupal\file_mdm\FileMetadataManager::__construct()" references interface "Psr\Log\LoggerInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "logger.channel.default", "logger.channel.php", "logger.channel.image", "logger.channel.cron", "logger.channel.file", "logger.channel.form", "logger.channel.security", "logger.channel.system", "logger.channel.file_mdm".

/var/www/html/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php:51
/var/www/html/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:80
/var/www/html/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php:29
/var/www/html/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:44
/var/www/html/vendor/symfony/dependency-injection/Compiler/Compiler.php:73
[...]

Proposed resolution

Add symfony/config:^6.2 package to composer.json (at least in the dev section if not in the runtime one).

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Closed: won't fix

Version

10.1

Component
Base 

Last updated about 11 hours ago

Created by

🇮🇹Italy mondrake 🇮🇹

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.

Production build 0.71.5 2024