Problem/Motivation
When someone adds a folder for config split, but the folder is not part of the repository or it's not yet created the configuration export fails with the following exception:
The .yml files in your export directory (../config/default) will be deleted and replaced with the active config. (y/n): y
InvalidArgumentException: The split storage has to be set and exist for write operations. in docroot/modules/contrib/config_split/src/Plugin/ConfigFilter/SplitFilter.php:166 [error]
Stack trace:
#0 docroot/modules/contrib/config_filter/src/Config/FilteredStorage.php(93): Drupal\config_split\Plugin\ConfigFilter\SplitFilter->filterWrite('block.block.adm...', Array)
#1 vendor/drush/drush/commands/core/config.drush.inc(518): Drupal\config_filter\Config\FilteredStorage->write('block.block.adm...', Array)
#2 vendor/drush/drush/commands/core/config.drush.inc(456): _drush_config_export('sync', '...', false)
#3 vendor/drush/drush/includes/command.inc(422): drush_config_export()
#4 vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#5 vendor/drush/drush/includes/command.inc(199): drush_command()
#6 vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#7 vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#8 vendor/drush/drush/drush.php(12): drush_main()
#9 {main}
The end result however is that all configuration yml files are already deleted, so this error is causing inconvenience.
If you are not using version control system with the configuration management, this exception will cause data-loss.
Proposed resolution
Attempt to create the split folder when writing to it before failing.
Remaining tasks
Discussion.
User interface changes
TBD.
API changes
TBD, none expected.
Data model changes
TBD, none expected.
Comments
Comment #2
bircherHello
Unfortunately the filter can not know what operation is being performed, it correctly fails when trying to write to a folder that does not exist.
We added a warning to the UI about this in #2906189: verify config directory exists in form validation.
We could try to create the folder if it doesn't exist before writing to it, but I am not sure that this is actually better or would create problems in other workflows. As such that would be a feature request.
There is no data loss even if you do not use git to track your configuration. All you have to do is create the folder and export the configuration again. The configuration export operation merely duplicates the data to the disk which exists also in the database.
Comment #3
bircherComment #4
irinaz commentedHi, I am using UI for config_split module /admin/config/development/configuration/config-split on a site that is built on Pantheon hosting. Currently I do not have git access to this site. I add new split configuration here /admin/config/development/configuration/config-split/test_config/edit and enter path for directory "../config/my-split-folder", and when I save I (correctly) get warning "The storage path "../config/my-split-folder" for test config Configuration Split Setting does not exist. Make sure it exists and is writable."
Is there a way to create this folder via UI? Do you need to get access to code and add empty folder in the root directory? What are best practices for this new module?
Thank you, Irina
Comment #5
aiphesI get this same error , while I change permissions on folders to 777:
I don't understand why this happen. If someone has an idea to fix it ?
Thanks
Comment #6
aiphesStill there on D8.8.2
Comment #7
bennlich commentedMaybe a compromise would be to print out the missing path in the error so that it's easy for the user to know what to create?
Comment #9
bircherI changed my mind...
There may still be some negative consequences, but we can always revert this if it turns out to out-weight the convenience.