Skip to content

fix(parallel): load the autoloader of the parent process in workers - #2058

Open
jfatr wants to merge 2 commits into
pestphp:5.xfrom
jfatr:fix/parallel-worker-autoload
Open

jfatr wants to merge 2 commits into
pestphp:5.xfrom
jfatr:fix/parallel-worker-autoload

Conversation

@jfatr

@jfatr jfatr commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

What:

  • Bug Fix
  • New Feature

Description:

A parallel worker looked for the Composer autoloader on its own, and it tried ../vendor/autoload.php before the checkout's own vendor/autoload.php. When a Pest checkout sits one level below a project that has a vendor directory, such as a Git worktree at <project>/<name>, each worker loaded that project's autoloader, and the run stopped with Cannot redeclare class ComposerAutoloaderInit….

bin/pest now keeps the autoloader it loaded in $GLOBALS['_composer_autoload_path'], and the wrapper runner passes it to each worker with --composer-autoload. The worker loads that file first and keeps the previous search as the fallback, so the Composer proxy, direct execution, nested vendor directories, global installs and path repositories behave as before.

tests/Visual/ParallelWorkerAutoload.php builds a checkout below a project whose vendor/autoload.php is a decoy, then runs bin/pest --parallel. Without the change the decoy runs and the test fails. Project::scaffoldCheckout shares its scaffold with scaffoldVendor.

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 this pull request may close these issues.

1 participant