1

I am struggling to install a drupal site from an existing configuration. Here the two approaches I tried:

OPTION 1: Import the config by changing the UID:

  • drush cex on existing site
  • drush site:install to install new site
  • drush cset system.site uuid 478e7e74-fea3...... to set UUID on new site equal to exisiting site
  • drush cim on new site

RESULT:

  The import failed due to the following reasons:

  Unexpected error during import with operation delete for taxonomy.vocabulary.tags: Attempt to create a field body that does not exist on entity type node.
  Unexpected error during import with operation delete for shortcut.set.default: Attempt to create a field body that does not exist on entity type node.
  Unexpected error during import with operation delete for contact.form.personal: Attempt to create a field body that does not exist on entity type node.

.... (There are many more of these errors, but I stripped them here for better readability)

OPTION 2: Provide existing config during installation already

drush site:install --existing-config with config from existing site being avilable in config directory of new site.

RESULT:

The selected profile has a hook_install() implementation and therefore can
not be installed from configuration.
3

I think option 1 is more of a hacky workaround than a recommended approach. I would avoid it in favor of option 2.

Re: option 2 failing, the error message is pretty clear - you can't use the --existing-config option with a profile that implements an install hook.

From the change record introducing the ability to install from existing configuration:

If the profile implements hook_install() configuration install is not supported. This might be addressed in #2982052: Allow an install hook in profiles installing from configuration. Possible workarounds for now are to either change the install profile to minimal or follow option 2 and create a new profile that does not implement the hook.

Drupal 8: Install Site From Existing Configuration walks through how to change your installation to use the minimal profile instead of your current profile. Spoiler: you just need to make two updates to the core.extension.yml file in your config directory:

  1. Change the profile key's value to minimal
  2. Under the modules key, replace your existing profile's key with minimal. (Profiles will typically be near the bottom of the list.)
5
  • Thanks a lot! This at least allows me to install from an existing config. However, I have to change the core.extension.yml before every run of drush cim to make it work. Is there a way around that as well?
    – Extect
    Jul 4 at 18:17
  • 1
    That shouldn't be necessary. You should be able to install the site with the changed core.extension.yml and export your config (drush cex) after the install finished. After this, you should just have a regular site needing no special treatment.
    – sonfd
    Jul 4 at 18:32
  • I have a dev site (with install profile standard) that I want to install cleanly in prod (which is possible by changing core.extension.yml thanks to your hint). Now, when I want to do a config change in dev and push it to prod, I would do a drush cex in dev and a drush cim in prod, but this won't work without changing core.extension.yml again. What am I getting wrong?
    – Extect
    Jul 4 at 18:37
  • After you do a fresh install on prod you need to bring that database (and config) back to your dev instance. It sounds like you're trying to do two separate fresh installs (one on dev and then a second on prod) and then deploy code between them as though they were the same site. AFAIK, this is not supported.
    – sonfd
    Jul 4 at 18:43
  • Ok. Thanks! I just wanted to get rid of all my test content in dev by doing a fresh install for prod. Probably my mistake was to not sync to two right away.
    – Extect
    Jul 4 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.