3

After I clear the cache, I get this message.

Symfony\Component\DependencyInjection\Exception\RuntimeException: You have requested a non-existent parameter "app.root". in Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass->processValue() (line 37 of /var/www/call/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php). Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass->processValue() (Line: 60) Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->processValue() (Line: 30) Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass->processValue() (Line: 39) Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->process() (Line: 140) Symfony\Component\DependencyInjection\Compiler\Compiler->compile() (Line: 789) Symfony\Component\DependencyInjection\ContainerBuilder->compile() (Line: 1335) Drupal\Core\DrupalKernel->compileContainer() (Line: 916) Drupal\Core\DrupalKernel->initializeContainer() (Line: 477) Drupal\Core\DrupalKernel->boot() (Line: 707) Drupal\Core\DrupalKernel->handle() (Line: 19)

Do you have any idea on how to solve this problem?

6
  • The second line says You have requested a non-existent parameter "app.root". Try searching your code base for app.root and see where you are requiring it. Feb 20, 2022 at 5:56
  • All are related to drupal console Feb 20, 2022 at 6:14
  • What version of Drupal console? Are you sure the version is compatible with 8.9.20? Feb 20, 2022 at 6:18
  • "drupal/console": "^1.9", Feb 20, 2022 at 6:21
  • Remove Drupal Console and retry.
    – leymannx
    Feb 20, 2022 at 6:34

2 Answers 2

3

This error is caused by code using %app.root% as parameter in Drupal 8.

For example:

   cache.backend.apcu:
     class: Drupal\Core\Cache\ApcuBackendFactory
     arguments: ['%app.root%', '%site.path%', '@cache_tags.invalidator.checksum']

This is Drupal 9 code not working in Drupal 8.

The service argument @app.root on the other hand is not causing this error. You find it in Drupal Console or other Drupal 8 code. It was deprecated in Drupal 9, but is still working until you update to Drupal 10. Then it will be this error "Non-existent service" errors after clearing the cache

See the change record https://www.drupal.org/node/3080612.

3

The app.root parameter has been added in Drupal 9 to replace the app.root service. If you are using Drupal 8, that error could possibly be causes by:

  • A module that says to be compatible with Drupal 8 and Drupal 9, whose code accesses the app.root container parameter when it runs on Drupal 8
  • Other code that tries to access the app.root container parameter when it runs on Drupal 8

This could happen because:

  • One of the arguments for a service is '%app.root%' (which requires the container parameter) instead of '@app.root' (which requires the service that exists in Drupal 8.x)
  • There is code that uses $container->getParameter('app.root') instead of $container->get('app.root')
  • There is code that checks whether to use the app.root container parameter or the app.root service, but it fails to use the available one

To understand which code causes the error, it should be sufficient to search for %app.root% or ->getParameter('app.root'). Searching for app.root isn't sufficient, as it would return any line that correctly uses the app.root service.

[Symfony 5] Replace app.root and site.path string services with container parameters has been created has been created on August 13, 2019 and marked as fixed on December 23, 2020. (The patch was committed on Drupal 9.x on March 5, 2020.)
Drupal Console 1.9.4 (released on November 11, 2019) should not contain code that accesses the app.root container parameter, as Drupal core didn't even have that container parameter when Drupal Console 1.9.4 was released.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.