Skip to content

Install the bundled PHP atomically to fix Windows first-launch site start failures - #5179

Merged
youknowriad merged 1 commit into
trunkfrom
fix-bundled-php-install-race
Oct 17, 2026
Merged

youknowriad merged 1 commit into
trunkfrom
fix-bundled-php-install-race

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

Related issues

  • Related to Windows e2e flakiness (Buildkite build 23034: sites.test.ts › preserves an existing MySQL wp-config.php, site-navigation.test.ts › opens site at homepage, sites.test.ts › duplicates a site)

How AI was used in this PR

Claude Code read the Windows e2e log, traced every failed attempt to the bundled-PHP migration, and wrote the fix and test. I reviewed the diagnosis and the change.

Proposed Changes

  • On first launch, the Desktop app starts several CLI processes at once, and each runs the migration that copies the bundled PHP into ~/.studio/php-bin. On Windows, one copy can hit a locked file. Its error handler then deleted the whole PHP folder, including the files the other process had just copied, and the delete itself threw (ENOTEMPTY/EPERM), so that CLI command failed too.
  • That left a PHP folder with php.exe but most of its extensions gone. The migration only checks whether the folder exists, so it never repaired it, and sites failed to start with "PDO Driver for SQLite is missing". Every failed attempt in the Windows e2e run above shows this sequence. Users on a fresh Windows install can hit the same thing.
  • Each process now copies into its own staging folder and renames it into place, so the PHP folder only ever appears complete. A process that loses the race discards its own copy and leaves the installed folder alone.
  • Not covered here: anyone whose PHP folder is already broken needs to delete it once. A similar, non-fatal EBUSY race on the bundled WordPress copy still shows up in the logs.

Testing Instructions

  • npm test -- apps/cli/migrations/tests/06-install-bundled-default-php.test.ts. The new case fails on trunk, where the copy overwrites a folder another process already installed.
  • Check that Windows e2e no longer shows ENOTEMPTY ... php-bin or "PDO Driver for SQLite is missing" from createSite.
  • Optional, on Windows: delete ~/.studio/php-bin, launch Studio and create a site. It should start.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

🤖 Generated with Claude Code

…cesses can't leave it half-deleted on Windows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 55b7230 vs trunk

app-size

Metric trunk 55b7230 Diff Change
App Size (Mac) 930.76 MB 930.76 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk 55b7230 Diff Change
load 1169 ms 1154 ms 15 ms ⚪ 0.0%

site-startup

Metric trunk 55b7230 Diff Change
siteCreation 8563 ms 8579 ms +16 ms ⚪ 0.0%
siteStartup 5916 ms 5892 ms 24 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@youknowriad
youknowriad merged commit f35d20a into trunk Oct 17, 2026
13 checks passed
@youknowriad
youknowriad deleted the fix-bundled-php-install-race branch October 17, 2026 19:05
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.

2 participants