Score:0

Install module with required config that may exist

ca flag

I have a module that have some config in config/install folder, that require config that may already exist in the current config. So I placed those config under config/optional.

But if those config does not exist, they are not installed and the module installation throw an error for unmet dependancies.

What can I do to have a module that have dependancies on config that may exist ?

Thanks.


More information:

Under config/install : core.entity_view_display.user.user.teaser_resource.yml

langcode: fr
status: true
dependencies:
  config:
    - core.entity_view_mode.user.teaser_resource
    - field.field.user.user.field_firstname
    - field.field.user.user.user_picture
  module:
    - user
id: user.user.teaser_resource
targetEntityType: user
bundle: user
mode: teaser_resource
content:
  field_firstname:
    type: string
    label: hidden
    settings:
      link_to_entity: false
    third_party_settings: {  }
    weight: 0
    region: content
hidden:
  langcode: true
  member_for: true
  realname: true
  search_api_excerpt: true
  user_picture: true

Under config/optional: field.field.user.user.field_firstname.yml

langcode: fr
status: true
dependencies:
  config:
    - field.storage.user.field_firstname
  module:
    - user
id: user.user.field_firstname
field_name: field_firstname
entity_type: user
bundle: user
label: Prénom
description: ''
required: true
translatable: false
default_value: {  }
default_value_callback: ''
settings: {  }
field_type: string

(field.storage.user.field_firstname.yml is also there)

The error is :

Unable to install Custom Module due to unmet dependencies: core.entity_view_display.user.user.teaser_resource (field.field.user.user.field_firstname)

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.