When creating a Split Setting the Static/Folder field says that it is permissible to leave the folder blank and those configurations won't be written. If Split setting has a folder defined, but the folder doesn't exist the following error is return on config-export

exception 'InvalidArgumentException' with message 'The split storage has to be set and exist for write operations.' in /var/www/docroot/sites/default/modules/config_split/src/Plugin/ConfigFilter/SplitFilter.php:167 [error]
Stack trace:
#0 /var/www/docroot/sites/default/modules/config_filter/src/Config/FilteredStorage.php(93): Drupal\config_split\Plugin\ConfigFilter\SplitFilter->filterWrite('action.settings', Array)
#1 phar:///usr/local/bin/drush/commands/core/config.drush.inc(507): Drupal\config_filter\Config\FilteredStorage->write('action.settings', Array)
#2 phar:///usr/local/bin/drush/commands/core/config.drush.inc(445): _drush_config_export('sync', 'profiles/oig_go...', false)
#3 [internal function]: drush_config_export()
#4 phar:///usr/local/bin/drush/includes/command.inc(422): call_user_func_array('drush_config_ex...', Array)
#5 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#6 [internal function]: drush_command()
#7 phar:///usr/local/bin/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#8 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#9 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#10 phar:///usr/local/bin/drush/includes/startup.inc(458): drush_main()
#11 phar:///usr/local/bin/drush/includes/startup.inc(365): drush_run_main(false, '/', 'Phar detected. ...')
#12 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#13 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#14 {main}

This causes the config-export to fail.

I see two possible solutions...

  1. Upon form submission and validation verify the directory exists and warn the user to create it.
  2. Change the error message that shows on the command line to actually say "The destination directory /var/www/path/to/directory doesn't exist so we cannot save the configuration export."

Comments

jrglasgow created an issue. See original summary.

bircher’s picture

Category: Bug report » Feature request
Issue summary: View changes

Hi

Thanks for opening this issue, however this is not a bug. The export fails as expected when the directory doesn't exist.

I agree that the message could be improved and we could even throw a custom exception. (This would still print the stack trace depending on your settings.) I don't have strong feelings on what the message should be.

Warning that the folder doesn't exist on the form submission is also a good idea but there are legitimate cases when the folder doesn't exist so I would not impede the form submission in such cases. (The folder property is overwritten in settings.php for example).

cristiroma’s picture

Assigned: Unassigned » cristiroma
cristiroma’s picture

Status: Active » Needs review
StatusFileSize
new848 bytes

Attaching a patch that checks the directory really exists and is writable. If not it shows an warning like

"The storage path /path/to/drupal/test_split for test_split Configuration Split Setting does not exists or is not writable."

  • bircher committed acba611 on 8.x-1.x
    Issue #2906189 by cristiroma: verify config directory exists in form...
bircher’s picture

Status: Needs review » Fixed

Thanks!

I removed the check if it is writable because the website user which runs the frontend doesn't need to have write access to the folder.

  • bircher committed 5ece182 on 8.x-1.x
    Issue #2906189: Improve warning text and use same function as in filter
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.