Uh oh!
There was an error while loading. Please reload this page.
fix: Repair the phar build on PHP 8.4. - #46
Merged
Conversation
"composer build" failed with 'Command "compile" is not defined' on checkouts that predate the box 2.7.5 -> 4.6.1 bump, and box 4.6.1 does not run on PHP 8.4 at all. - ScriptHandler::installPharTools only created the tool symlink when it was missing, so vendor/bin/box kept pointing at the box 2.7.5 phar of the previously pinned URL. Update the symlink unconditionally and keep it relative, so it survives the project being mounted at another path. - The phar was only downloaded when its file name was absent, so a new version published under the same name was never picked up. Record the installed URL and re-download whenever the pinned URL changes, removing the phar of the previously pinned version. - dumpFile() ignored the mode argument, leaving the downloaded phar non-executable. Set the mode via chmod(). - Pin box 4.7.0: 4.6.1 aborts on PHP 8.4 after emitting 260 implicit-nullable deprecations. - README: drop the deprecated "composer install --dev". Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ouHkvipwQik1mwsrrBmUd
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 freeto 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.
Follow-up to #45 (merged). Refs #43.
Problem
composer build— the command needed to produce a new phar for a 0.7.3 release — is broken:Not a regression from #45. It is a latent bug since 69ac445 (Dec 2024), which bumped the pinned box from
box2/2.7.5/box-2.7.5.phartobox/4.6.1/box.phar. Fresh clones happened to work, which is why it went unnoticed; any checkout that predates that bump is broken.Root cause
Two independent defects in
ScriptHandler::installPharTools():a) The tool symlink was never repointed.
On a pre-bump checkout
vendor/bin/boxalready existed, pointing at the leftoverbox-2.7.5.phar. The newbox.pharwas downloaded — different basename, so the download guard let it through — but nothing ever linked to it. Socomposer buildkept invoking box 2.7.5, whose command isbuild, notcompile. Hence the error.b) The download was keyed on the file name only.
A new box published under the same
box.pharname would never be fetched, so the next version bump would have silently kept the old binary.Fix
The installer now reconciles
vendor/binwith the currently pinned URL:vendor/bin/.<tool>.url;box -> box.phar) so it keeps working when the project directory is mounted at another path, e.g. inside a container.Two smaller bugs surfaced along the way:
$fs->dumpFile($path, $content, 0755)—Filesystem::dumpFile()takes no mode argument, so the third one was silently ignored and the downloaded phar was left non-executable (-rw-rw-r--). Now set explicitly viachmod().composer install --dev→composer install(--devis a no-op that Composer 2 warns about and Composer 3 will reject).Box pinned 4.6.1 → 4.7.0
Box 4.6.1 (Dec 2023) does not run on PHP 8.4 at all, so even with the symlink fixed
composer buildcould not produce a phar there:4.7.0 still builds on PHP 8.3 too, so this does not force maintainers onto 8.4.
Verification
Verified:
vendor/binstate (abox -> box-2.7.5.pharsymlink) and runningcomposer install && composer build→[InvalidArgumentException] Command "compile" is not defined.composer installrepointsbox -> box.phar(4.7.0), andcomposer buildproducesphapp.phar.rm -rf vendor && composer install && composer buildsucceeds;vendor/bin/box.pharis now correctly-rwxr-xr-x..box.urlrecording 4.6.1 andcomposer.jsonpinning 4.7.0,composer installre-downloads and the symlink follows.list,status).composer validate→ valid (lock content-hash refreshed viacomposer update --lock; no package versions changed);php -lclean.Not verified / caveats:
git-versionremoved from the box config, because the barephp:8.4-cliimage has nogitbinary and my sandbox could not install one. That setting only substitutes the version placeholder and is orthogonal to the PHP version; the full config includinggit-versionwas verified on PHP 8.3. The deprecation counts above come from identical configs, so the 4.6.1-vs-4.7.0 comparison is unaffected.phpstan analyse src --level=0still reports the same 2 pre-existing errors insrc/ScriptHandler.php(Composer\Script\Event/Composer\Util\StreamContextFactoryunknown —composer/composeris not a dependency). Count unchanged by this PR.vendor/bin/box-2.7.5.phar, since there is no record of it to clean up. It is no longer referenced and is harmless;rm -rf vendorclears it.Why this matters for #43
#43 is only actually fixed for consumers once a 0.7.3 phar is released, and that phar cannot be built on PHP 8.4 without this PR.
🤖 Generated with Claude Code
https://claude.ai/code/session_018ouHkvipwQik1mwsrrBmUd