diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php
index 73acd845afa291d68f8bb4896406ee73b8e70363..bd281a1b3c72b42559f4d9f70a65e786ba035437 100644
--- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php
+++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php
@@ -33,7 +33,7 @@ public function __construct(string $app_root = NULL) {
     if ($app_root === NULL) {
       // @todo https://www.drupal.org/project/drupal/issues/3087975 Require
       //   $app_root argument.
-      \Drupal::hasService('app.root') ? (string) \Drupal::service('app.root') : DRUPAL_ROOT;
+      $app_root = \Drupal::hasService('app.root') ? (string) \Drupal::service('app.root') : DRUPAL_ROOT;
     }
     $this->root = $app_root;
   }