I am creating two custom content type with reference to these pages:



Everything works fine. Content type with fields is created. But While installing, it throws an exception and as a result hook_install is not executing, i think. The error is as follows:

Uncaught PHP Exception Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException: "You have requested a non-existent service "router.route_provider.old". Did you mean one of these: "router.route_provider", "router.route_preloader"?" at ...\\core\\lib\\Drupal\\Component\\DependencyInjection\\Container.php line 157

Could anyone please help me, why this is happening and how to fix it ?

I am using Drupal 8.1.8 version.

#7 2788087-7.patch1.1 KBdawehner
Members fund testing for the Drupal project. Drupal Association Learn more


shafiqhossain created an issue. See original summary.

shafiqhossain’s picture

Title: Drupal 8: The “boolean_checkbox” plugin does not exist » Drupal 8: You have requested a non-existent service "router.route_provider.old"
Issue summary: View changes
shafiqhossain’s picture

I checked in core.services.yml file, there is no route declared as "router.route_provider.old"

shafiqhossain’s picture

I have created a router names as "router.route_provider.old" by copying "router.route_provider" in the core.services.yml file, which solves my problem.

i think Drupal uses "router.route_provider.old" router as a temporary to copy "router.route_provider" router info. But as this router name is not exists, its throwing exception.

I don't know if this is a bug or there is better way to fix it.

dawehner’s picture

Component: plugin system » extension system

Thank you for reporting this issue. This is certainly interesting

Can you show your exact code you try to use? In theory the router.route_provider.old should be always available, but well, maybe you cause a container rebuild in your hook_install() code which could cause this issue.

shafiqhossain’s picture

Here is my hook_install() function. Its creating 2 terms and clear the cache, that's all.

function adplus_install() {
  $locations = ['Front', 'Inner']; // List of ad location
  foreach ($locations as $location) {
    $term = \Drupal\taxonomy\Entity\Term::create([
      	'vid' => 'adplus_ad_location',
      	'name' => $location,
	  	'parent' => array(),
  //clear all caches

Is clearing the cache creating the issue ?

dawehner’s picture

Status: Active » Needs review
1.1 KB

Yeah this probably causes the issue.

Do you mind trying out the patch from below? It should fix the issue, ideally.

shafiqhossain’s picture

Yes the patch working well and fixes the issue. Thank you.

alexpott’s picture

@shafiqhossain - you shouldn't be clearing the cache like that during a module install though. It's just not necessary.

shafiqhossain’s picture

Unless I clear the cache after installation, my new content types are not displaying in the content type list. In order to see the new content types in the list, I have to manually clear the cache from Performance page.

dawehner’s picture

Do you mind uploading the entire module? This would be super helpful for debugging reasons.

shafiqhossain’s picture

thursday_bw’s picture

Status: Needs review » Reviewed & tested by the community

Had the same issue when calling \Drupal::service('module_installer')->uninstall(['search']); uninstall from hook_install()

patch #7 does the trick.. Looks like a simple fix.

dawehner’s picture

IMHO it should be possible to write a test for that.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Yes it should.

fizk’s picture

I just ran into this as well. I was trying to uninstall the Drupal-core Search module in hook_install():


 * Implements hook_install().
function mymodule_install() {
  // Disable Drupal-core Search module.
  if (\Drupal::moduleHandler()->moduleExists('search')) {
Web-Beest’s picture

I ran into this issue (Drupal 8.3.1) as well.

I have a hook_install that disables another modules which generated the error.

I can confirm this patch works for me.

kamkejj’s picture

Also ran into this on 8.3.x with a install profile that's enabling modules in the .install file. The patch did work.

EclipseGc’s picture

Issue tags: -Plugin system

Not plugin related

slydevil’s picture

Patch from #7 works for me as well.