2

I have this error when importing a single piece of config manually:

Configuration foo.api depends on the MODULE extension that will not be installed after import.

There is no "MODULE" extension in the file system, core.extension config, the KeyValue table, config_snaphot, or anywhere else that I'm aware of that would be related.

If I delete the config

\Drupal::configFactory()->getEditable('foo.api')->delete();

Then try the import, it works. Great.

But as soon as I go back to my config form and save foo.api, the next time I try to import, I get the same error all over again.

This leads me to believe that a dependency tree must be stored somewhere, and that it isn't cleared when config is deleted.

Is this true, and if so where is it? If not, how can I resolve this?

I guess this could also be rephrased as How are module dependencies for basic configuration calculated, and how do you manually update them when they’re wrong?

1 Answer 1

3

The error you see is output from ConfigImportSubscriber::validateDependencies(), which uses the following code.

  // Validate the dependencies of all the configuration. We have to validate
  // the entire tree because existing configuration might depend on
  // configuration that is being deleted.
  foreach ($config_importer
    ->getStorageComparer()
    ->getSourceStorage()
    ->listAll() as $name) {

    // Ensure that the config owner is installed. This checks all
    // configuration including configuration entities.
    list($owner, ) = explode('.', $name, 2);
    if ($owner !== 'core') {
      $message = FALSE;
      if (!isset($core_extension['module'][$owner]) && isset($module_data[$owner])) {
        $message = $this
          ->t('Configuration %name depends on the %owner module that will not be installed after import.', [
          '%name' => $name,
          '%owner' => $module_data[$owner]->info['name'],
        ]);
      }

The code assumes that for a name like node.type.article the owner is the Node module. If the owner is not one of the installed modules, Drupal gives the error you see.

To answer your question, the module name is assumed to be stored in the configuration filename.

2
  • 1
    Oh wow, I was off on a wild goose chase looking for something far more complicated. Thank you for bringing me back!
    – Clive
    Commented Aug 21, 2018 at 17:30
  • I was wondering too what would happen with a configuration that doesn't declare its dependencies.
    – avpaderno
    Commented Aug 21, 2018 at 17:42

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.