Skip to main content

drush cim: Unable to install the module since it does not exist. Drupal 8. But the module is there!

Updated by Tim Rabbetts on
programming, computer, environment

As part of my deployment I use ansible and docker-compose.  The ansible script calls drush cim within the docker container via docker compose.  It fails everytime I enable a new module and pass it up as part of config.

Unable to install the module since it does not exist. in Drupal\Core\Config\ConfigImporter->validate() (line 755 of /var/www/drupal/web/core/lib/Drupal/Core/Config/ConfigImporter.php). 
In ConfigImportCommands.php line 357:

I debugged this code and found the code that issues this error: core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php

// Get a list of modules with dependency weights as values.
$module_data = $this->moduleExtensionList->getList();
$nonexistent_modules = array_keys(array_diff_key($core_extension['module'], $module_data));
foreach ($nonexistent_modules as $module) {
  $config_importer->logError($this->t('Unable to install the %module module since it does not exist.', ['%module' => $module]));
}

I debug the variables and find that the $module_data which should be the new list of all modules in the modules folder is missing my module, but the file system has it.

Of course its the cache, added drush cr step before my drush cim and all works perfect now!  Hope this helps someone.

Add new comment