Skip to content

fix: ignore packages bundled in a PHAR when detecting installed packages - #2059

Open
jfatr wants to merge 1 commit into
pestphp:5.xfrom
jfatr:fix/init-laravel-detection
Open

jfatr wants to merge 1 commit into
pestphp:5.xfrom
jfatr:fix/init-laravel-detection

Conversation

@jfatr

@jfatr jfatr commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

What:

  • Bug Fix
  • New Feature

Description:

InstalledVersions::isInstalled() reads the installed.php of every registered Composer loader, not only the project's. A tool that the PHP binary loads before Pest, such as Laravel Herd's dump.phar through auto_prepend_file, registers its own loader, and that loader declares laravel/framework. On such a machine pest --init writes the Laravel stubs in a project without Laravel, and the generated suite stops with The class or trait [Tests\TestCase] could not be found. The parallel Laravel handler and the TIA watch defaults read the same data.

Pest\Support\InstalledPackages reads InstalledVersions::getAllRawData() and skips each installed set whose root lives inside a PHAR. It answers like isInstalled() for everything else, including development requirements and sets without install_path. Every call site in src now uses it.

  • tests/Features/Init.php builds a small PHAR that declares laravel/framework, loads it with -d auto_prepend_file, and checks that --init writes the plain stubs.
  • tests/Unit/Support/InstalledPackages.php covers the filter and checks that no other class in src reads InstalledVersions.
  • tests/.snapshots/success.txt and tests/Visual/Parallel.php count the new tests.

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