Skip to content
Latchkey

PHPUnit "Cannot open bootstrap script" in CI

PHPUnit loads a bootstrap file (usually vendor/autoload.php) before running tests. When that file does not exist in CI - typically because composer install was skipped or run with the wrong working directory - PHPUnit cannot start.

What this error means

PHPUnit aborts before any test with "Cannot open bootstrap script \"vendor/autoload.php\"" or a similar path. The bootstrap configured in phpunit.xml is not present on disk.

composer
PHPUnit 10.5.0 by Sebastian Bergmann and contributors.

Cannot open bootstrap script "vendor/autoload.php".

Common causes

Dependencies were never installed

composer install did not run (or failed), so vendor/autoload.php was never generated and the bootstrap path is missing.

Wrong working directory or bootstrap path

PHPUnit runs from a directory where the relative bootstrap path does not resolve, or phpunit.xml points at the wrong file.

How to fix it

Install dependencies before running tests

Generate the autoloader so the bootstrap exists.

Terminal
composer install --no-interaction --prefer-dist
vendor/bin/phpunit

Fix the bootstrap path and working directory

  1. Confirm phpunit.xml bootstrap points at the real autoloader (e.g. vendor/autoload.php).
  2. Run PHPUnit from the project root so the relative path resolves.
  3. Re-run the suite.

How to prevent it

  • Always run composer install before PHPUnit in CI.
  • Keep the phpunit.xml bootstrap path correct relative to the project root.
  • Run PHPUnit from the repository root in CI steps.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →