Skip to content

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

@cburschka

Description

@cburschka

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.

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions