Drupal 8 Configuration Management -dealing with import issues

Chandeep Khosa
Aug 27, 2016 · 4 min read
Thanks to ChromaticHQ for this image

I was recently using Drupal 8’s awesome Configuration Management to export configuration from my local environment to a Dev environment and ran into an error. I’ll explain how I fixed it below.

Exporting config from my Local site

I exported my configuration on my local site by running ‘drush cex’.

Next I saw a list of all files that had been ‘created’, ‘updated’ or ‘deleted’.

drush cex (part 1)
drush cex (part 2)

I had successfully exported my config to my repository and next proceeded to commit these changes with git add -A; git commit -m “configuration changes”; git push.

Importing config to my Dev site

As my repository was hosted on Pantheon, I didn’t need to pull in my commits to the Dev environment as it works automatically. With other hosting providers you may need to do this manually with another process or install a tool such as Capistrano.

I was now ready to pull in my changes on my Dev site. This can be done in one of two ways

a) with the drush command ‘drush cim’

b) in the Drupal UI

I chose the Drupal UI as it allows you to deal with conflicts and give you confidence that you’re not overwriting good configuration. I opened the ‘Configuration Synchronisation’ page available at /admin/config/development/configuration and saw the following :

Preparing to import config on the ‘Configuration Synchronisation’ page

It explains which configuration files had changed and allowed me to ‘view differences’ :

I reviewed these changes and was happy to proceed as everything was as expected, so I clicked on the ‘Import all’ button.

Unfortunately as you can see above, this is where I received an error message that prevented me from importing until the problem was resolved.

  • The configuration cannot be imported because it failed validation for the following reasons:
  • Configuration bootstrap_sass_starterkit.settings depends on the bootstrap_sass_starterkit extension that will not be installed after import.

This was occurring because for some reason I had forgotten to fully uninstall the ‘bootstrap_sass_starterkit’ theme after I decided to re-use a theme I’d built from another project. I looked at the ‘Appearance’ page and ‘Uninstall’ page under the Modules section but unfortunately couldn’t see any mention of the theme. I also tried clearing all caches and running database updates before re-trying also without success.

Deleting my configuration file manually

I decided that the only way to fix this was to delete the individual configuration YAML file manually, so I reviewed my configuration files and deleted the file ‘bootstrap_sass_starterkit.settings.yml’ with the command “rm -rf sites/default/config/bootstrap_sass_starterkit.settings.yml”. I then committed this change to my repository.

SUCCESSFULLY importing config to my Dev site

I wanted to confirm if this had indeed fixed the issue so I tried to import again. This did and after I clicked the ‘Import all button’ this time I saw the process complete. I checked that my new changes had successfully applied and they had!

Fixing my local configuration

If I didn’t do anything else, the next time I would have run ‘drush cex’ I would have the same issue again as my active config still has those configurations, and when I export the local config again, it will simply export it again.

Instead to fix this I had to import the config into your local environment by running ‘drush cim’.

Learning : it is import to fully uninstall modules & themes when removing them

When you remove modules and themes it is important to uninstall them properly as they leave traces in your database that can cause issues later.


Advanced configuration management

You can choose to only work on individual configuration files when working with other developers when you want to using the Configuration Split module.

If you’d like certain configuration excluded because you’d like content editors to be able to change things without your exported configuration overwriting their work, you can use Drush CMI tools.

Chandeep Khosa

Written by

Freelance #Drupal 8 & Front End Developer | #Drupal8 Core contributor | Organiser @DrupalWLondon

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade