Fix project root resolution when vendor is a symlinked directory (git worktree support)#1752
Open
ceilidhboy wants to merge 7 commits into
Open
Fix project root resolution when vendor is a symlinked directory (git worktree support)#1752ceilidhboy wants to merge 7 commits into
ceilidhboy wants to merge 7 commits into
Conversation
Applies the same symlinked-vendor detection logic from bin/pest to bin/worker.php, but extracted into a single reusable function instead of duplicating the inline check at two call sites.
When the worktree detection corrects the root path for symlinked vendor directories, also set ['APP_BASE_PATH'] so that Laravel's inferBasePath() picks up the correct worktree path instead of falling back to the autoloader path (which points to the symlinked origin worktree). This eliminates the need for a per-worktree APP_BASE_PATH override in phpunit.xml.
…s ^4.x constraints
The same block of code for resolving the project root path when vendor is a symlinked directory (git worktree support) existed in both bin/pest (inline) and bin/worker.php (as a local function). Extracted it to a dedicated internal class so there is one definition shared by both entry points.
Covers four scenarios for worktree root resolution: - Normal project (no symlink) - Worktree with matching vendor symlink - Worktree with vendor symlink pointing elsewhere - Worktree with real vendor directory (not a symlink) Also verifies the ['APP_BASE_PATH'] side effect.
ceilidhboy
marked this pull request as ready for review
July 12, 2026 09:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What:
Description:
When running Pest from a git worktree where
vendor/is a symlink to another worktree (e.g. to avoid the overhead of duplicating dependencies), the project root path was incorrectly resolved to the parent of the resolved vendor directory rather than the worktree root.The root cause is that PHP's
__DIR__and__FILE__resolve through symlinks. Sincebin/pestlives inside thevendor/directory, ifvendor/is a symlink then__DIR__follows it, causingdirname(__DIR__, 4)to point at the wrong worktree's root. The same issue affectedbin/worker.phpfor parallel test execution.The fix checks whether the current working directory has a
vendorsymlink that resolves to the same location as the autoloader's vendor parent. If so, the CWD is used as the project root.Related:
For detailed background on the worktree + symlinked vendor use case, see the wiki page on my fork.