Problem

When exporting a full export there should be an option to export all of the configuration without UUIDs, so that I can—if I want to—import my config into a site that was not cloned from the site I am exporting from, but shares the same codebase. This is already a common use case for me and will be, I think, at least as common as importing from a clone.

Proposed resolution

Either

  1. Add a checkbox to the export form "include UUIDs in exported configuration" [description] "Configuration going to a clone of this site should include UUIDs, if configuration is being moved to another site, UUIDs will conflict and should not be included. Configuration will then overwrite configuration of the same name."
  2. Or the “import” tab could have the (unchecked) option “Strip UUIDs from imported config" [description] "If configuration originates from a different site (not a clone of this site) UUIDs must be stripped before import, Imported configuration will then overwrite configuration of the same name."
  3. Or (ideally) when the sync process detects that the config is from a different site, present the user with a dialog that says "This configuration appears to be from a different site (not a clone of this site), Import anyway? y/n Imported configuration will overwrite existing site configuration of the same name.

Related issues

#2628144: Ensure that ConfigImport is taking place against the same code base

Comments

tkoleary created an issue. See original summary.

tkoleary’s picture

Title: Option to strip UUIDs from imported config files » Add an option to strip UUIDs from imported/exported config files
tkoleary’s picture

Issue summary: View changes
tkoleary’s picture

dawehner’s picture

IMHO the actual solution is to point people to https://www.drupal.org/project/config_installer

There is a reason why this feature is not allowed. Feel free to read more on https://www.drupal.org/node/2133325

tkoleary’s picture

I fully agree with Moshe's comment (#34) in that issue, (paraphrasing) to allow the user to override and import config from a different site if they want.

The fact of the matter is that people who are aware of the potential risks are already doing this by manually removing the UUIDs but that's a painful process (even if I write a script to grep and auto-remove them) and there are plenty of other places in core where we provide a "do this at your own risk" type of warning.

tkoleary’s picture

@dawhener

https://www.drupal.org/project/config_installer is only useful if I want to install a new site, not port configuration to an existing site.

dawehner’s picture

Well, I think making it super hard for people to break their site is not a bad thing.

xjm’s picture

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dgtlmoon’s picture

There's kind of a similar thread over at github/drush https://github.com/drush-ops/drush/pull/1875

dawehner’s picture

Well, IMHO the thing is that drush is for advanced users, for which we are fine to break stuff, as they maybe have good reasons for certain actions.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mlncn’s picture

Our primary use case for this feature is for feature building.

The config/sync directory is never used to import, but it can be used to check if the result of a `site install` is about what we expect (and to copy wanted files or changes we wanted to keep, and missed, from a saved version).

The meaningless UUID changes in every file, however, make it impossible to find that information in all the noise.

Here is a workaround that presumes you are using Git for version control, exporting configuration and committing it, then running a site install, and re-exporting the configuration (but not yet committing it):

git diff -G '^[^u]*([^u][^i][^d][^:]).*'

will show only files with non-uuid changes. If there's a change to a uuid other than the one for the configuration as a whole (that is, indented under some other part of the configuration), that will be shown.

Super unsure about the regex in this but it's not had a false negative or positive yet.

Here's what i have in my .bashrc to make this easier to use:

# Diff that ignores config files whose only change is the UUID (ignores lines
# starting with 'uuid:' and probably other stuff but it's solid so far.)
alias gdu="git diff -G '^[^u]*([^u][^i][^d][^:]).*'"

Took me forever to come up with this workaround; hope it helps others.

And yes i would still like the option in drush!

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

colan’s picture

And yes i would still like the option in drush!

I'd recommend creating an issue in the Drush queue then. Please link to it from here. (I just checked, and it doesn't exist.)

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mrpauldriver’s picture

Did this get anywhere with with Drush?

All my Drupal 8 sites (30+) are clones of the same code base and I expect this is a common scenario for many not working in the enterprise space.

Aside from Drush, surely it is time for a more flexible approach to configuration management.

What is happening with this?

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

colan’s picture

Here's another workaround, which edits the files in place. Note the differences with folks not using GNU sed. (This is the Linux version; see there for how to modify if you're using BSD, or still use Apple products for some reason.)

#!/bin/bash
FILES=$CONFIG_DIR/*
for f in $FILES
do
  echo "Processing $f file..."
  sed -i '/^uuid:/d' $f
  sed -i '/^\_core:/d' $f
  sed -i '/^  default_config_hash:/d' $f
done
bircher’s picture

Status: Active » Closed (won't fix)

I do not think core should have this feature. See the discussion of why UUIDs for config were added in the first place: #2133325: Create a site UUID on install and only allow config sync between sites with the same UUID

That said, of course people wanting this have a valid use case. All I am saying is that core shouldn't deal with this. Especially since it is very easy to create a contrib module which strips out uuids on export and re-sets them on import to the one that exist already (or random ones if they don't exist).

All one has to do is use the config transformation API added to Drupal 8.8
https://www.drupal.org/node/3066005

Config Split 2.x and Config Ignore 3.x are examples of modules that implement their functionality with this API.
I am also available on slack if someone wants help building such a module.

loopy1492’s picture

If you are maintaining a drupal profile and have a long and complex config/install folder, it sure would have been nice to have an option to export to that install folder without the uuids present. Having to strip those out is a huge pain.

Found this online:

```
sed -i.bak '/^uuid: /d' ./*
```