It is expected that for a module which adds a dependency to .info.yml it must be enabled in an update hook, rather than Config Distro reading .info.yml and enabling modules with its config updates?

Created on 16 October 2023, about 1 year ago

Problem/Motivation

It was not clear to us that dependencies added to .info.yml would not be enabledโ€” until running into a bunch of errors about configuration in the same modules' config/install directories not importing because dependent modules were not there.

So these modules must be enabled in an update hook?

Was it ever considered that Config Distro read the .info.yml and enable modules as part of its configuration updates?

It's not explicitly documented one way or another.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ’ฌ Support request
Status

Active

Version

2.0

Component

Documentation

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States mlncn Minneapolis, MN, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mlncn
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States trackleft2 Tucson, AZ ๐Ÿ‡บ๐Ÿ‡ธ

    We also run into this issue constantly... You would think Drupal Core would read info files and enable any modules added to the info file of a module as dependencies.

    On its face it sounds like any easy issue to solve, but what if the module doesn't exist in the codebase until composer update is run, or isn't even in composer.json at all.

    The fact that we have literally three dependency management systems to contend with here is fairly daunting.

    At the very least we could add a section to the readme that includes some instructions for adding new module dependencies.

    For example in you module's my_module.install file

    /**
     * Ensure module dependencies are installed .
     */
    function my_module_update_1020801() {
      $array_of_dependencies = [
        'module_1',
        'module_2',
      ];  
      \Drupal::service('module_installer')->install($array_of_dependencies);
    }
    

    In your module's my_module.info.yml file, add modules to the dependecies array

    name: My Module
    type: module
    description: 'Example module description'
    core_version_requirement: ^9 || ^10
    package: 'Custom Modules'
    
    php: 8.1
    
    dependencies:
      - module_1:module_1
      - module_2:module_2
    
    
Production build 0.71.5 2024