Dealing with Drupal 9 errors: Symfony\ Component\ DependencyInjection\ Exception\ Service Not Found Exception: The service “pathauto.generator” has a dependent service “token.entity_mapper
A couple of times with websites running on Drupal Version 9.x when I got stuck with below and similar errors:
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The service “pathauto.generator” has a dependen
service “token.entity_mapper”… in /vendor/symfony/dependency-injection/Compiler/
All was running well, until I installed a contributed module Taxonomy Views Integrator (TVI) using composer require, ran drush updb, and drush cache:rebuild, when boom! The error…
Here some quick fixes:
- Update Drupal core to the latest, if not done yet (make sure you have a good backup of both the website files and database which you can restore if anything goes wrong).
composer update "drupal/*" --with-all-dependencies
drush updatedb
drush cache:rebuild - Check your PHP versions if inadvertently or previously set lower than PHP version 8.0
I had one in instance where my PHP version had been unintentionally set to 7.x. Changing PHP version to 8.x made the error go away. - Update your contributed modules to the latest versions; if necessary, to the dev versions of modules that may be causing the error.
In another case which I experienced, since the error seems to point to instances within pathauto and token modules, I had to re-install both by running composer require commands for the stable versions as recommended by the project module pages.
In my case:
composer require ‘drupal/pathauto:^1.11’
composer require ‘drupal/token:^1.11’
drush updb
drush cache:rebuild
Side notes:
While updating contributed modules using composer, another error may appear which seems to prevent the re-installation of the modules:
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
Could not delete …/sites/default/default.settings.php:
To fix the above, run below Linux command (this will temporarily allow the necessary permissions for the D9 modules installation):
chmod u+w sites/default
Then proceed with the re-installation of the modules.
This article and similar troubleshooting articles are also found in iBuild.PH Knowledgebase for Drupal and other CMS https://knowledgebase.ibuild.ph/.
For full Drupal support and managed services in web design and development, you may also reach out to us through our Drupal web development services page at www.ibuild.ph/drupal.
I hope this helps!