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

[config:export] directory incorrectly prefixed with composer root #4245

Closed
cburschka opened this issue May 19, 2020 · 2 comments · Fixed by #4246
Closed

[config:export] directory incorrectly prefixed with composer root #4245

cburschka opened this issue May 19, 2020 · 2 comments · Fixed by #4246

Comments

@cburschka
Copy link
Contributor

cburschka commented May 19, 2020

Problem/Motivation

In #4154 / 37aeb5d, ExportCommand was modified to prefix the config sync directory with the composer root. Three bugs:

  1. 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.
  2. The composer root is actually prefixed twice when making the directory.
  3. 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'; in settings.php (already the default for this composer template).
  • Run drupal config:export

Expected:

  • Config is exported to ../config/sync from Drupal root (which is config/sync from Composer root).

Actual:
several issues (getting a different one on each environment where I reproduced it):

  1. Tries to create {COMPOSER_ROOT}/{COMPOSER_ROOT}/../config/sync
  2. 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)

cburschka added a commit to cburschka/drupal-console that referenced this issue May 19, 2020
- Use Drupal root, not Composer root.
- Avoid adding the root to an already absolute path.
- Avoid adding the root twice when creating the directory.
@cburschka
Copy link
Contributor Author

This seems to be reported in several other issues, including #4195 and #4198.

pinoniq referenced this issue in pinoniq/drupal-console Feb 15, 2021
[config:export] fix path construction (#4245)
LOBsTerr pushed a commit that referenced this issue Sep 16, 2022
- Use Drupal root, not Composer root.
- Avoid adding the root to an already absolute path.
- Avoid adding the root twice when creating the directory.
@LOBsTerr
Copy link
Member

THank you for your contribution

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

Successfully merging a pull request may close this issue.

2 participants