Problem/Motivation

Installing Drupal via the web installer with pathauto enabled crashes at the "Configure site" step with:

You have requested a synthetic service ("kernel"). The DIC does not know how to construct this service.

During installation the container is not yet compiled and @kernel is registered as synthetic (not yet set). PathautoEntityHooks and PathautoTokensHooks trigger a dependency chain that reaches @kernel at instantiation time, causing the fatal error.

Steps to reproduce

  1. Fresh Drupal 11 install with pathauto in the install profile or enabled during setup
  2. Run the web installer
  3. Observe fatal error at "Configure site"

Proposed resolution

Mark pathauto.generator, PathautoEntityHooks and PathautoTokensHooks as lazy: true in pathauto.services.yml and add the corresponding proxy classes generated via core/scripts/generate-proxy-class.php. This defers service instantiation until after the kernel is available.

Issue fork pathauto-3601236

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nicoschi created an issue. See original summary.

nicoschi’s picture

Issue summary: View changes
berdir’s picture

Status: Active » Postponed (maintainer needs more info)

lazy is discouraged and I have no idea why this would fix such an error, I've just days ago did an installer of a profile including pathauto, which did not have this problem.

Need more information on how to reproduce this, what the error with full backtrace is.

nicoschi’s picture

Hi berdir, despite the lazy solution maybe being a workaround which did the trick for me the problem exists, for sure with latest version of Drupal 11 and pathauto. These are the step i used again to reproduce it:
- I created a custom profile in which I included in info.yml only modules from Standard profile plus pathauto
- I executed the installation with that profile
- the error was triggered after submission of the step 6 (Configure site):

Symfony\Component\DependencyInjection\Exception\RuntimeException: You have requested a synthetic service ("kernel"). The DIC does not know how to construct this service. in Symfony\Component\DependencyInjection\ContainerBuilder->createService() (line 1104 of /var/www/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php).

Symfony\Component\DependencyInjection\ContainerBuilder->createService() (Line: 637)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (Line: 1320)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1272)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1172)
Symfony\Component\DependencyInjection\ContainerBuilder->createService() (Line: 637)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (Line: 1320)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1272)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1799)
Symfony\Component\DependencyInjection\ContainerBuilder->callMethod() (Line: 1228)
Symfony\Component\DependencyInjection\ContainerBuilder->createService() (Line: 637)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (Line: 1320)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1272)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1172)
Symfony\Component\DependencyInjection\ContainerBuilder->createService() (Line: 637)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (Line: 1320)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1272)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1172)
Symfony\Component\DependencyInjection\ContainerBuilder->createService() (Line: 637)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (Line: 1320)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1272)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1172)
Symfony\Component\DependencyInjection\ContainerBuilder->createService() (Line: 637)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (Line: 1320)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1272)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1172)
Symfony\Component\DependencyInjection\ContainerBuilder->createService() (Line: 637)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (Line: 582)
Symfony\Component\DependencyInjection\ContainerBuilder->get() (Line: 28)
Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (Line: 100)
Drupal\Core\Utility\CallableResolver->getCallableFromDefinition() (Line: 751)
Drupal\Core\Extension\ModuleHandler->getHookImplementationList() (Line: 338)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 299)
Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions() (Line: 204)
Drupal\Core\Entity\EntityFieldManager->getBaseFieldDefinitions() (Line: 357)
Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions() (Line: 1214)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables() (Line: 503)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->mapFromStorageRecords() (Line: 428)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->getFromStorage() (Line: 394)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->doLoadMultiple() (Line: 340)
Drupal\Core\Entity\EntityStorageBase->loadMultiple() (Line: 267)
Drupal\Core\Entity\EntityStorageBase->load() (Line: 277)
Drupal\Core\Installer\Form\SiteConfigureForm->submitForm() (Line: 108)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 45)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 615)
Drupal\Core\Form\FormBuilder->processForm() (Line: 347)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 963)
install_get_form() (Line: 612)
install_run_task() (Line: 565)
install_run_tasks() (Line: 122)
install_drupal() (Line: 53)

isavdz’s picture

I can confirm this issue also occurs with `drush site:install` (Drush 13.7.3) on Drupal 11.3.12, not only via the web installer.

Environment:
- Drupal 11.3.12
- Pathauto 1.15.0
- Drush 13.7.3
- Custom install profile including pathauto

The error occurs at the same point (SiteConfigureForm::submitForm) and with the same backtrace as reported by nicoschi.

After debugging with a temporary error_log() in ClassResolver::getInstanceFromDefinition(), I confirmed that `Drupal\pathauto\Hook\PathautoEntityHooks` is the last class resolved before the crash. This class is declared with `autowire: true` in pathauto.services.yml, which triggers a transitive dependency chain reaching `theme.registry`, which depends on `@kernel` — unavailable during install.

Workaround: remove pathauto from the install profile's info.yml and move pathauto-related config (pathauto.pattern.* and core.base_field_override.*.path.yml) out of config/install/ before running drush si, then enable pathauto and reimport the config after install.

Here is the content of my backtrace

[info] update module installed.

In ContainerBuilder.php line 1104:

[Symfony\Component\DependencyInjection\Exception\RuntimeException]
You have requested a synthetic service ("kernel"). The DIC does not know how to construct this service.

Exception trace:
at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1104
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:637
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1320
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1272
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1172
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:637
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1320
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1272
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1799
Symfony\Component\DependencyInjection\ContainerBuilder->callMethod() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1228
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:637
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1320
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1272
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1172
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:637
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1320
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1272
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1172
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:637
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1320
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1272
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1172
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:637
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1320
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1272
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:1172
Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:637
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /path/to/my-drupal-site/vendor/symfony/dependency-injection/ContainerBuilder.php:582
Symfony\Component\DependencyInjection\ContainerBuilder->get() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php:28
Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Utility/CallableResolver.php:100
Drupal\Core\Utility\CallableResolver->getCallableFromDefinition() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Extension/ModuleHandler.php:751
Drupal\Core\Extension\ModuleHandler->getHookImplementationList() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Extension/ModuleHandler.php:338
Drupal\Core\Extension\ModuleHandler->invokeAllWith() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Entity/EntityFieldManager.php:299
Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Entity/EntityFieldManager.php:204
Drupal\Core\Entity\EntityFieldManager->getBaseFieldDefinitions() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Entity/EntityFieldManager.php:357
Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1214
Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:503
Drupal\Core\Entity\Sql\SqlContentEntityStorage->mapFromStorageRecords() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:428
Drupal\Core\Entity\Sql\SqlContentEntityStorage->getFromStorage() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:394
Drupal\Core\Entity\Sql\SqlContentEntityStorage->doLoadMultiple() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Entity/EntityStorageBase.php:340
Drupal\Core\Entity\EntityStorageBase->loadMultiple() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Entity/EntityStorageBase.php:267
Drupal\Core\Entity\EntityStorageBase->load() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php:277
Drupal\Core\Installer\Form\SiteConfigureForm->submitForm() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Form/FormSubmitter.php:108
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Form/FormSubmitter.php:45
Drupal\Core\Form\FormSubmitter->doSubmitForm() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Form/FormBuilder.php:615
Drupal\Core\Form\FormBuilder->processForm() at /path/to/my-drupal-site/www/core/lib/Drupal/Core/Form/FormBuilder.php:521
Drupal\Core\Form\FormBuilder->submitForm() at /path/to/my-drupal-site/www/core/includes/install.core.inc:978
install_get_form() at /path/to/my-drupal-site/www/core/includes/install.core.inc:612
install_run_task() at /path/to/my-drupal-site/www/core/includes/install.core.inc:565
install_run_tasks() at /path/to/my-drupal-site/www/core/includes/install.core.inc:122
install_drupal() at /path/to/my-drupal-site/vendor/drush/drush/includes/drush.inc:69
drush_call_user_func_array() at /path/to/my-drupal-site/vendor/drush/drush/includes/drush.inc:53
drush_op() at /path/to/my-drupal-site/vendor/drush/drush/src/Commands/core/SiteInstallCommands.php:174
Drush\Commands\core\SiteInstallCommands->install() at n/a:n/a
call_user_func_array() at /path/to/my-drupal-site/vendor/consolidation/annotated-command/src/CommandProcessor.php:276
Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback() at /path/to/my-drupal-site/vendor/consolidation/annotated-command/src/CommandProcessor.php:212
Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter() at /path/to/my-drupal-site/vendor/consolidation/annotated-command/src/CommandProcessor.php:175
Consolidation\AnnotatedCommand\CommandProcessor->process() at /path/to/my-drupal-site/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:389
Consolidation\AnnotatedCommand\AnnotatedCommand->execute() at /path/to/my-drupal-site/vendor/symfony/console/Command/Command.php:341
Symfony\Component\Console\Command\Command->run() at /path/to/my-drupal-site/vendor/symfony/console/Application.php:1117
Symfony\Component\Console\Application->doRunCommand() at /path/to/my-drupal-site/vendor/drush/drush/src/Application.php:201
Drush\Application->doRunCommand() at /path/to/my-drupal-site/vendor/symfony/console/Application.php:356
Symfony\Component\Console\Application->doRun() at /path/to/my-drupal-site/vendor/symfony/console/Application.php:195
Symfony\Component\Console\Application->run() at /path/to/my-drupal-site/vendor/drush/drush/src/Runtime/Runtime.php:113
Drush\Runtime\Runtime->doRun() at /path/to/my-drupal-site/vendor/drush/drush/src/Runtime/Runtime.php:40
Drush\Runtime\Runtime->run() at /path/to/my-drupal-site/vendor/drush/drush/drush.php:140

berdir’s picture

Kernel should always exist, also in the installer? Not sure why autowire would trigger this, you could for testing explicitly specify the services to see if that makes difference? Is something resetting the container? You could try to see if #3575642: Always free up old container on rebuild, not only in the installer resolves the issue for you.

The service creation chain is extremely deep in both cases. Try debugging the chain through doResolveServices() what services are getting instantiated.

mark_fullmer made their first commit to this issue’s fork.

mark_fullmer’s picture

Here is some more data isolating the problem:

1. It can be reproduced via the UI, per the original issue writeup, using the following:
- Drupal Core 11.3.x
- Pathauto 8.x-1.15
- An installation profile that includes drupal:pathauto as enabled in the info.yml file, and nothing else, e.g.,

name: TestOnly
type: profile
description: Test installation profile
core_version_requirement: '^10 || ^11'
version: '1.0.0'
distribution:
  name: Test
dependencies:
  - drupal:pathauto

2. It cannot be reproduced with Pathauto 8.x-1.14.

3. The changes in #3550710: Convert to OOP hooks, which was the first commit after the 8.x-1.14 tag, trigger the problem -- specifically the use of dependency injection in the new OOP hooks.

3. Precisely, the instantiation of ConfigFactoryInterface via the class constructor, using dependency injection, in src/Hook/PathautoEntityHooks.php, is the root cause. While it is probably not acceptable to the maintainers of Pathauto to use static calls for the services, https://git.drupalcode.org/project/pathauto/-/merge_requests/181 does prevent the issue in a cleaner way that using lazy loading of the services.

4. The Drupal core merge request in #3575642: Always free up old container on rebuild, not only in the installer also resolves the issue, but that issue looks like it still has a ways to go before it is committed.

Given that the proposed change in Drupal core prevents the issue, this should probably be considered not a bug within PathAuto, per se, but this issue should probably be left active until the issue is resolved in core. Merge request https://git.drupalcode.org/project/pathauto/-/merge_requests/181 could be considered a temporary workaround with minimal change, until the issue is resolved in core.

mark_fullmer’s picture

Status: Postponed (maintainer needs more info) » Active
berdir’s picture

I think that's a core bug that an unclean container reset happens. We did in fact fix installer memory usage by doing the container reset only there.

Specifically, the problem is that \Drupal\Core\Installer\Form\SiteConfigureForm::submitForm installs a module and then continuous to use services from the old container through $this->entityTypeManager. If you change that to \Drupal::entityTypeManager() then that will also fix this I assume.

Fixing that and/or #3575642: Always free up old container on rebuild, not only in the installer is IMHO the only correct way forward. a workaround in pathauto with a todo might be an option, but pathauto is doing everything correctly.

berdir’s picture

Looks like this was in fact fixed in #3573856: SiteConfigureForm properties need to be reset after module install in submitForm() but that wasn't backported to 11.3. You should be able to either wait for 11.4 or use either of the core issues as a patch.

mark_fullmer’s picture

I can confirm that #3573856: SiteConfigureForm properties need to be reset after module install in submitForm() does indeed fix the error. Thanks, @berdir. Given this, I think this issue can be closed as "works as designed."

berdir’s picture

Status: Active » Closed (duplicate)

Thanks for confirming, closing as duplicate.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.