Skip to content

[6.x] Fix Composer script events crashing when locating composer.json - #15434

Merged
jasonvarga merged 2 commits into
6.xfrom
fix-composer-env
Sep 9, 2026
Merged

[6.x] Fix Composer script events crashing when locating composer.json#15434
jasonvarga merged 2 commits into
6.xfrom
fix-composer-env

Conversation

@jasonvarga

Copy link
Copy Markdown
Member

#15362 switched Json::filename() to Illuminate\Support\Env::get('COMPOSER'). That call is reachable from the pre-update-cmd hook, and Composer registers only the class autoloader for script events — it never runs the autoload.files entries, so none of Laravel's helper functions exist.

Env::get() evaluates value($default) when the variable is missing, so every composer update / composer require fataled with Call to undefined function Illuminate\Support\value(). Setups actually using the COMPOSER env var were unaffected, since that takes the other branch.

Reads the env var in vanilla PHP instead, using the same lookup order as Env.

jasonvarga and others added 2 commits September 9, 2026 11:05
Composer registers the class autoloader for script events but never runs the
autoload.files entries, so Laravel's helper functions don't exist. Env::get()
evaluates value($default) when the variable is missing, which fataled every
composer update/require via the pre-update-cmd hook.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Exercising Lock::backup() rather than the filename methods means anything
later added anywhere the hook reaches is covered, not just the leaf.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jasonvarga
jasonvarga merged commit af746b4 into 6.x Sep 9, 2026
64 checks passed
@jasonvarga
jasonvarga deleted the fix-composer-env branch September 9, 2026 16:34
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.

1 participant