Skip to content

Call to a member function make() on null during package discovery (still broken in latest Laravel version) #58023

@sameededitz

Description

@sameededitz

Laravel Version

12.41.1

PHP Version

8.4.15

Database Driver & Version

MySQL (8.4.2)

Description

I'm currently running into the same issue that was previously reported here:
#56098
(opened on 22 Jun)

Even though that issue is closed, the problem still exists in the latest Laravel release.

When running composer install or composer update, package discovery fails with:

Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Error 

  Call to a member function make() on null

  at vendor\laravel\framework\src\Illuminate\Console\Command.php:171
    167▕      */
    168▕     #[\Override]
    169▕     public function run(InputInterface $input, OutputInterface $output): int
    170▕     {
  ➜ 171▕         $this->output = $output instanceof OutputStyle ? $output : $this->laravel->make(
    172▕             OutputStyle::class, ['input' => $input, 'output' => $output]
    173▕         );

This makes Composer commands unusable because artisan package:discover crashes.

What I tried:

composer dump-autoload
php artisan clear-compiled
deleting bootstrap/cache/packages.php & services.php
reinstalling vendor folder
checking for broken service providers

as in previous issue it states:

If I put $this->laravel = app(); into the Command's constructor manually then run composer update again then it works well, but I can't do that on deploy or live environment.

it works but do i need to use it still

Please reopen the previous issue or provide a fix.
Currently, any project hitting this state cannot run Composer updates at all.

Steps To Reproduce

composer install
composer update

During post-autoload-dump, Laravel runs:
@php artisan package:discover --ansi

The command fails with:
Error: Call to a member function make() on null
The process stops and Composer cannot complete the install/update.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions