Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow config-import to be skipped when config is empty #2701

Open
grasmash opened this issue Mar 30, 2017 · 9 comments
Open

Allow config-import to be skipped when config is empty #2701

grasmash opened this issue Mar 30, 2017 · 9 comments

Comments

@grasmash
Copy link
Contributor

grasmash commented Mar 30, 2017

Currently, if you try to execute drush config-import and the config directory is empty, you will receive an error like this:

Drupal\Core\Config\ConfigImporterException: There were errors        [error]
validating the config synchronization. in
Drupal\Core\Config\ConfigImporter->validate() (line 728 of
/home/travis/build/acquia/blt-project/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php).
The import failed due for the following reasons:                     [error]
This import is empty and if applied would delete all of your
configuration, so has been rejected.

At first, I tried to workaround this by checking to see if the config directory was empty prior to import. However, if you're using something like config_split, your config directory may change depending on environment. It's not easy (from the CLI) to know which directory to check. This makes it difficult to create a good CI build.

So, I propose adding a --skip-if-empty option to drush config-import that will skip configuration import without failure if the config directory is empty.

@bircher
Copy link
Contributor

bircher commented Mar 30, 2017

I am not per-se against it, but I am also not sure how this can happen without being an error of some sort.
Config Split allows you to fragment/segment/split the one config directory into smaller ones and lets you decide which ones to include. But you will always need to have a canonical sync directory where you have your core.extension.yml and possibly some other core and system config. Config Split is not meant to completely replace a configuration directory as you could have done that before already with several directories specified in $config_directories. Config Sync only works with the default by default. you can make it work with every config storage, however.

So an empty config directory seems to be an error. If a split directory is empty it will just simply not add anything to the sync directory when importing and you wouldn't get the failure you are getting.

@balaji1006
Copy link

I have tried to execute drush config-import, it will get the same error.

[error] Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization. in Drupal\Core\Config\ConfigImporter->validate() (line 728 of /home/local/RAGE/balajir/projects/drupal/cdstdev/drupal/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php).
[error] The import failed due to the following reasons:
This import is empty and if applied would delete all of your configurations, so has been rejected.

Please provide the any solution

@davereid-pfg
Copy link

I could also use this. We have our own internal version of drupal-project that uses the drush deploy command. For testing our project, our config directory is naturally empty, just like drupal-project, but now the deploy command fails since it doesn't exist.

@djdevin
Copy link

djdevin commented Sep 10, 2020

+1, empty config directory because all configuration is deployed via code. Would be nice to still use drush deploy

@weitzman
Copy link
Member

because all configuration is deployed via code

Are the config files not in your repo? That would be a non-standard workflow. You can't easily stage/test configuration changes.

Is that true for other people in this issue? I'm not really understanding the reasoning behind this request.

@davereid-pfg
Copy link

We are definitely encountering web teams that lack active developers, that do not want to manage their config via code, and want to only rely on the active config in the database. It would be nice if our tooling that uses drush deploy could work for those sites as well.

@weitzman
Copy link
Member

I'm ambivalent. Any thoughts, @alexpott or @bircher?

@alexpott
Copy link
Contributor

I think the deploy command could have a skip config import option. But I think calling config import and the directory being empty should always fail.

@weitzman
Copy link
Member

Thanks @alexpott. Your suggestion makes sense. Yet I looked into implementation, and nothing makes more sense to me than folks just using this 3 line custom script:

drush udpatedb
drush cr
drush deploy:hook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants