#1606794: Implement new routing system added a new routing system, which is pulled out of drupal_container.
Something isn't being built early enough when using drush.

$ drush cc all
WD php: Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: The service definition "router.builder" does not exist. in       [error]
Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition() (line 690 of
/Users/tim/www/d8/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php).
Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: The service definition "router.builder" does not exist. in Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition() (line 690 of /Users/tim/www/d8/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php).
Drush command terminated abnormally due to an unrecoverable error.

Comments

moshe weitzman’s picture

Project: Drush » Drupal core
Version: » 8.x-dev
Component: Core Commands » base system

Drush does a full bootstrap and then calls drupal_flush_all_caches(). I think that function is assuming a web request which is not always true. That function makes the fatal call to drupal_container(). Moving this bug to Drupal core.

moshe weitzman’s picture

Title: Services cannot be retrieved from drupal_container() in most drush commands » drupal_flush_all_caches() assumes a web request - "The service definition "router.builder" does not exist. "
Issue tags: +WSCCI, +symfony, +wscci-hitlist
Crell’s picture

This is yet another facet of the "Drupal doesn't work without a Kernel" problem, which is a factor in several issues. The solution to all of them is "always use a kernel". For command line, the ideal solution is "put the Console component in core, and use a kernel with it."

yesct’s picture

moshe weitzman’s picture

Status: Active » Fixed

I played with this a bit today and fixed the cache-clear problem by doing in drush a lot of what index.php is doing

     drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);
    // global $kernel;
    $kernel = new Drupal\Core\DrupalKernel('prod', drush_get_context('DRUSH_DEBUG', FALSE));
    $kernel->boot();

This instantiates an httpkernel which makes no sense for a cli request but works for now. Hopefully someone can share some pseudocode which lets us setup an App kernel or whatever is appropriate.

There is a similar error in drush site-install command but i can't bear to debug the installer right now. Anyway, this is now fixed for all drush commands that do full bootstrap.

Automatically closed -- issue fixed for 2 weeks with no activity.