[Drupal 8] use sed (on OSX) to strip the uuid line from exported config files being used for module default configuration; i.e. [module_name]/config/optional|install
NOTE: this can also by bypassed in the export by using Drupal Cnnsole and including the --remove-uuid
flag. Also using the --remove-config-hash
flag can help prevent additional headaches.
Ex:
drupal config:export --directory=”[full-path-to-location]” --tar --remove-uuid --remove-config-hash
The UUID should never be included when using when using these exported config yaml files as the default configuration pagaged with a custom module. This is suppoedly not to be a thing in the exported yaml files at some point, but until then stripping the uuid line out is a manual process which can be a pain as there can be a lot of files.
To automate this, run the following sed command in the directory containing the yaml files:
sed -i.bak '/^uuid: /d' ./*
The i.bak
arg will create a backup of the affected file. When satistifed with the results, you can safely get rid of the .bak files:
rm *.bak
References:
@gaellafond Thank you for your feedback. I don't recall what this was needed for - as it was posted here 5-6 years ago - but obviously the intent was to provide a default configuration to be included-with and set upon custom module installation. I reviewed the config_split issue that you referenced as well as this gist, some notes I found from back then, and did a little quick research as to any 'official' recommendation/best practice for including a default config with custom module. The following documentation from drupal.org which provides a recommendation for this specific feature actually supports removing the UUID line(s) from the accompanying bundled YAML config file(s):
https://www.drupal.org/docs/creating-modules/include-default-configuration-in-your-drupal-module
I haven't worked with D8 in the years since this was originally posted and only recently moved back to developing for D9 from Laravel and other platforms. It looks like this solution is still viable though it may need a tweak or two - no idea. If you or anyone else who happens to stumble across this has any better recommendations/solutions for including default configs for application upon custom module install, please feel free to post them. Otherwise, feel free to use this method. If/when I find myself needing this functionality again, I will revisit and post any updates, tweaks, fixes, et al here. Cheers!