drupal-console
drupal-console copied to clipboard
[config:export] directory incorrectly prefixed with composer root
Problem/Motivation
In #4154 / 37aeb5d12, ExportCommand was modified to prefix the config sync directory with the composer root. Three bugs:
- A relative path is relative to Drupal root, which is not the same as the composer root - many sites created via composer put Drupal in a
./web/
subdirectory. - The composer root is actually prefixed twice when making the directory.
- The path might already be absolute, in which case it should not be prefixed with anything at all.
How to reproduce
Include steps related how to reproduce.
- Create a Drupal site using the
drupal-composer/drupal-project
template (https://github.com/drupal-composer/drupal-project) - Require
drupal/console
^1.9.4 - Set
$settings['config_sync_directory'] = '../config/sync';
insettings.php
(already the default for this composer template). - Run
drupal config:export
Expected:
- Config is exported to
../config/sync
from Drupal root (which isconfig/sync
from Composer root).
Actual: several issues (getting a different one on each environment where I reproduced it):
- Tries to create
{COMPOSER_ROOT}/{COMPOSER_ROOT}/../config/sync
- Tries to export to
{COMPOSER_ROOT}/../config/sync
Solution
A brief description of the proposed fix.
- Use Webmozart\PathUtil\Path to check if the directory is absolute
- If not, use
drupalFinder->getDrupalRoot()
and prefix the directory with that - Remove the extra prefixing when creating the directory.
(PR to follow)
This seems to be reported in several other issues, including #4195 and #4198.
THank you for your contribution