Repository navigation
Conversation
## Summary Fix local `vercel build` failures on macOS and Windows when Composer is executed through the bundled Linux PHP runtime. ## Changes - add host-aware PHP spawn configuration - use bundled libphp only on Linux - use local `php` on non-Linux hosts for local builds - replace the `which php php-cgi` check with a portable `php -v` check - return a clear error when local PHP is required but missing - add a regression test for Linux spawn configuration ## Why This fixes local build failures like: `Error: spawn Unknown system error -8` which happened because the runtime attempted to execute the packaged Linux PHP binary on non-Linux machines. ## Verification - `npm run build` - `npx jest --runInBand test/spec/utils.js` - manual check on Windows confirms the new explicit missing-PHP error path
denusklo
left a comment
There was a problem hiding this comment.
Tested the unchanged PR head 8f5f044 with real PHP on three hosts:
| Host | TypeScript / Jest | Runtime file collection | Composer install + vercel script |
|---|---|---|---|
| Windows, Node 22.19.0, local PHP 8.2.0 | Build passes; four existing Windows test failures | Fails at .mode, tracked separately in #651 |
Passes when tested directly |
| macOS arm64, Node 22.23.3, local PHP 8.4.26 | Pass | Pass | Pass |
| Ubuntu WSL2 x64, Node 22.23.2 | Pass | Pass | Pass with bundled PHP 8.5.2 |
The Composer smoke project has no external dependencies and a vercel script invoked through @php; this verifies actual install/script execution, not just the returned spawn configuration. Windows used an isolated PHP configuration rather than the old WAMP configuration on this machine.
One local-host concern remains in getPhpSpawnConfig() at lines 137–140: COMPOSER_HOME: '/tmp' overwrites the inherited value on macOS/Windows too. I set a disposable Composer home for the smoke test; the script saw /tmp on both hosts. This means local global Composer configuration and saved auth.json credentials won't be used. Could /tmp be confined to the bundled Linux branch, leaving the local PHP branch's Composer home untouched? This behavior was inherited from the Linux-only path, not newly broken on Linux.
A smaller issue at line 156: ensureLocalPhp() checks the parent environment, while the returned execution environment includes optsEnv. Passing the merged environment to the availability check would prevent false missing-PHP results when PATH is overridden. Current Composer callers don't pass overrides, so this is not a blocker for the default path.
It would be useful to add tests for the non-Linux success/missing-PHP branches and Composer-home preservation; the added test currently covers Linux only.
The Windows file-map crash is pre-existing and occurs before Composer. #651 addresses it separately; I don't consider it a regression in this PR.
Summary
Fix local
vercel buildfailures on macOS and Windows when Composer is executed through the bundled Linux PHP runtime.Changes
phpon non-Linux hosts for local buildswhich php php-cgicheck with a portablephp -vcheckWhy
This fixes local build failures like:
Error: spawn Unknown system error -8which happened because the runtime attempted to execute the packaged Linux PHP binary on non-Linux machines.
Verification
npm run buildnpx jest --runInBand test/spec/utils.js