Tried to rewrite config by module without initial config

Created on 6 June 2025, 4 months ago

Problem/Motivation

In Drupal 11.2 the module installation was changed. See Issue #3416522 . Installing multiple modules does not rebuild the container between installations. So using config_rewrite when installing a module's dependency leads to an error.

<!--break-->

Steps to reproduce

Install a module with a dependency to another module and config rewrite for that module.
For example:
my_eu_cookie_compliance.info.yml

name: 'My EU Cookie Compliance Settings'
type: module
core_version_requirement: ^11
dependencies:
  - 'config_rewrite:config_rewrite'
  - 'eu_cookie_compliance:eu_cookie_compliance'

config/rewrite/eu_cookie_compliance.settings.yml

cookie_lifetime: 100

Installing my_eu_cookie_compliance leads to folling error:
Tried to rewrite config eu_cookie_compliance.settings by my_eu_cookie_compliance module without initial config.

(This is not a problem with eu_cookie_compliance. I just used it in this example, because that's how we found this behavior.)

When container_rebuild_required is set to true in my_eu_cookie_compliance.info.yml, everything works as expected.

🐛 Bug report
Status

Active

Version

1.6

Component

Code

Created by

🇩🇪Germany hosterholz

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

Comments & Activities

  • Issue created by @hosterholz
  • 🇺🇸United States jrockowitz Brooklyn, NY

    Attached is a very ugly workaround that (re)enables container rebuild for all modules as they are installed in Drupal 11.2+.

    I don't think this is the best solution. Ideally, when a config rewrite is about to happen, the container could be rebuilt, but I couldn't figure out how to achieve this.

  • 🇮🇳India vishalkhode

    With Drupal core 11.2, they've added a new key i.e container_rebuild_required . That needs to be added in module's info.yml.

Production build 0.71.5 2024