Skip to content

Support projects with a custom Composer vendor-dir #6

Description

@renatonascalves

Problem

The run-parallel executable cannot find Composer's autoloader when a project uses a custom vendor-dir.

Our project has this Composer configuration:

{
  "config": {
    "vendor-dir": "client-mu-plugins/vendor"
  }
}

The executable is therefore installed at:

client-mu-plugins/vendor/bin/run-parallel

Running it from the project root:

client-mu-plugins/vendor/bin/run-parallel --command="composer lint"

fails with:

Class "Symfony\\Component\\Console\\Output\\ConsoleOutput" not found

The package bootstrap currently checks fixed paths and getcwd() . '/vendor/autoload.php'. None of those paths point to the custom Composer vendor directory when the command runs from the project root.

Composer's generated binary proxy already provides the correct autoloader path through:

$GLOBALS['_composer_autoload_path']

Request

Could the bootstrap use Composer's provided autoloader path when it is available?

For example:

if (isset($GLOBALS['_composer_autoload_path'])) {
    require_once $GLOBALS['_composer_autoload_path'];
    return;
}

The existing fallback paths could remain for cases where the executable is not launched through Composer's binary proxy.

Current workaround

We must first change into the custom vendor directory's parent, then tell run-parallel to execute commands from the project root:

cd client-mu-plugins \
  && vendor/bin/run-parallel --cwd=.. --command="composer lint"

This works, but it ties the command to our vendor directory layout. Supporting Composer's generated autoloader path would make the executable work directly from the project root.

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