Fix out-of-memory installs and surface Composer failure output - #61
Merged
Conversation
Booting Composer in-process skips the bin/composer bootstrap, so the user's php.ini memory_limit applied and large resolutions such as rector/rector crashed with an OOM that cpx swallowed into a one-line error. Mirror the bootstrap's memory bump (honoring COMPOSER_MEMORY_LIMIT) and include Composer's captured output in ComposerCommandException so failures are self-diagnosing.
WendellAdriel
marked this pull request as ready for review
July 23, 2026 17:06
WendellAdriel
requested review from
TitasGailius,
Copilot and
joetannenbaum
and removed request for
Copilot
July 23, 2026 17:06
TitasGailius
approved these changes
Jul 23, 2026
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.
Overview
Installing large packages like
rector/rectorfailed on machines with a finite php.inimemory_limit, reporting onlyComposer command failed: require rector/rector(or a misleading "Package not found" callout on older builds). The PHAR boots Composer in-process, which skips thebin/composerbootstrap that raisesmemory_limitto 1536M, so resolving rector + phpstan (needs more than 768M) died with a fatal OOM that cpx swallowed.Solution
ComposerRunner::runInProcess()now mirrors thebin/composerbootstrap: it honorsCOMPOSER_MEMORY_LIMIT, raises finite limits below 1536M to 1536M, and leaves-1or higher limits untouched.ComposerCommandExceptionalso appends Composer's captured output (ANSI-stripped and truncated) to its message, so the real diagnostic reaches both interactive and JSON output instead of an opaque one-liner.Details
This explains the "works on my machine" reports: plain
composer require rector/rectorsucceeds everywhere becausebin/composerbumps its own memory limit, while cpx failed only for users with a finitememory_limit(the stock PHP default is 128M). Reproducible withPHPRC=<ini with memory_limit=512M> cpx rector/rectoragainst a cleanCPX_HOME, which now installs and runs Rector. The distributed PHAR is rebuilt with the fix.