Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vnc00's avatar

composer update: Script php artisan clear-compiled handling the pre-update-cmd event returned with an error

Hey, I googled a lot, but can't find a solution for my problem.

When I type "composer update" into the terminal, it prints out:

Vincents-MBP:battlerap.club xxx$ composer update
> php artisan clear-compiled
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error


                      
  [RuntimeException]  
  Error Output:       
                      


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--] [<packages>]...


Vincents-MBP:battlerap.club xxx$ 

I don't have a boostrap/cache/compiled.php - file. Yesterday it works fine, I just added the package:

"pulkitjalan/google-apiclient": "2.*"

But I also tried to remove it with "composer update --no-scripts" but it still don't work. Please help me!

From Berlin, Vincent

0 likes
45 replies
ohffs's avatar

Are any of your service providers modified?

1 like
vnc00's avatar

@ohffs Yes, yesterday I added this one:


        PulkitJalan\Google\GoogleServiceProvider::class
ohffs's avatar

Try removing it - 'artisan' will boot up the framework so any service providers that get called and have an error will cause it to fail every time :-/

vnc00's avatar

@ohffs Removed the packages with "composer update --no-scripts" and removing it from composer.json. Also removed the alias and service provider in config/app.php but same error. :(

ohffs's avatar

Hrm - does 'composer dump-autoload' run ok? If you just run 'php artisan' does it crash?

vnc00's avatar
Vincents-MBP:battlerap.club xxx$ php artisan 
Vincents-MBP:battlerap.club xxx$ composer dump-autoload
Generating autoload files
Vincents-MBP:battlerap.club xxx$ php artisan 
Vincents-MBP:battlerap.club xxx$ php artisan
Vincents-MBP:battlerap.club xxx$ 

Nothing. "dump-autoload" changes nothing in my mind - the vendor/autoload.php was not changed - should it? :(

ohffs's avatar

It was just to be extra sure it was artisan that was the problem and not composer :-) Does your site still run ok in the browser?

ohffs's avatar

Are your storage/ & bootstrap/cache directory writeable by the webserver user?

vnc00's avatar

I think so. Days ago it worked and I changed nothing on the permissions. I'm using MAMP, if it is necessary fyi.

ohffs's avatar

Can do an 'ls -al storage', 'ls -al storage/logs' and 'ls -al bootstrap/cache'?

vnc00's avatar

The log works now.


ls -al storage:

Vincents-MBP:battlerap.club xxx$ ls -al storage
total 16
drwxr-xr-x   8 xxx  admin   272 12 Dez 14:28 .
drwxr-xr-x  29 xxx  admin   986 12 Dez 15:04 ..
-rwxr-xr-x@  1 xxx  admin  6148 12 Dez 14:30 .DS_Store
drwxr-xr-x   3 xxx  admin   102 29 Okt 20:32 app
drwxr-xr-x   4 xxx  admin   136 12 Dez 14:30 audio
drwxr-xr-x   7 xxx  admin   238 12 Dez 14:30 framework
drwxr-xr-x   4 xxx  admin   136 12 Dez 14:30 image
drwxr-xr-x   6 xxx  admin   204 12 Dez 15:27 logs
Vincents-MBP:battlerap.club xxx$ 

ls -al storage/logs:

Vincents-MBP:battlerap.club xxx$ ls -al storage/logs/
total 104
drwxr-xr-x  6 xxx  admin    204 12 Dez 15:27 .
drwxr-xr-x  8 xxx  admin    272 12 Dez 14:28 ..
-rwxr-xr-x@ 1 xxx  admin   6148 12 Dez 14:36 .DS_Store
-rwxr-xr-x  1 xxx  admin     14  1 Okt 13:00 .gitignore
-rwxr-xr-x  1 xxx  admin  40041 12 Dez 15:29 laravel-2015-12-12.log
-rwxr-xr-x  1 xxx  admin      0 12 Dez 14:37 laravel.log

ls -al bootstrap/cache

Vincents-MBP:battlerap.club xxx$ ls -al bootstrap/cache/
total 32
drwxr-xr-x  4 xxx  admin    136 12 Dez 13:14 .
drwxr-xr-x  5 xxx  admin    170 12 Dez 13:12 ..
-rwxr-xr-x  1 xxx  admin     14  1 Okt 13:00 .gitignore
-rwxr-xr-x  1 xxx  admin  11702 12 Dez 15:07 services.json
ohffs's avatar

Does 'php artisan' run ok now? I see in your other thread you changed the directory permissions?

vnc00's avatar

@ohffs php artisan doesn't work... the log-file works now (I did something wrong, my mistake), but not "php artisan". :( I've absolutely no idea.

I removed all service providers in config/app.php. But was it correctly how I did it?:

  1. classes removed in providers- & aliases - Array in config/app.php
  2. remove packages from composer.json
  3. composer update --no-scripts (remove the packages)
  4. php artisan clear-compiled (nothing happens, no output)
  5. php artisan optimize (nothing happens, no output)

Doesn't work.

I'm totally helpless..

ohffs's avatar

Is your code in a git repo? You could try stepping back a few commits until you find one where it works and then see what changed afterwards? And just to be extra sure - can you try 'cat artisan' just to make sure it's still what it should be?

vnc00's avatar

cat artisan:


Vincents-MBP:battlerap.club xxx$ cat artisan
#!/usr/bin/env php
<?php

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

require __DIR__.'/bootstrap/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

$status = $kernel->handle(
    $input = new Symfony\Component\Console\Input\ArgvInput,
    new Symfony\Component\Console\Output\ConsoleOutput
);

/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running. We will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/

$kernel->terminate($input, $status);

exit($status);
Vincents-MBP:battlerap.club xxx$ 

No its not in a repo.

ohffs's avatar

Ah.

Maybe try removing (or just renaming) the 'vendor' folder and re-running composer install? If that doesn't fix things then it's maybe something in your app/Providers - though it's odd that your app still runs ok in the browser.

vnc00's avatar

Doesn't work... I'm giving up for now, maybe I'll try it later. Arghh. If someone has got any idea, please let me know. Thanks.

StormShadow's avatar

@vnc00 what about manually deleting the services.json in bootstrap/cache (not using artisan clear-compiled) ?

Hope you get this sorted. I hope this gets fixed in 5.2 because it has happened to me before when I deployed to forge because it seems whenever you add to your providers, the composer update will fail because the framework is booted to run the clear-compiled command.

Keep us posted! :)

vnc00's avatar

@StormShadow I already deleted the services.json manually, without success.

Hope so. Thanks. :)

mathias87's avatar

Hey,

I have exactly the same problem and also no Idea how to fix that.. typing php artisan in console returns nothing and composer update / install returns same error after some steps. -> Script php artisan clear-compiled handling the post-install-cmd event returned with an error

I just want to follow this conversation :)

1 like
vnc00's avatar

Anyone who's another idea? I really need this to fix!

rags02's avatar

Worked for me:

After updating composer.jsonper the upgrade guide, to get all updated repo's:

composer update --no-scripts

Then: composer dump-autoload -o

Then, I ran an update again so my pre/post update scripts can run: composer update

App loads in browser and all my tests pass again using 5.2. Hope this helps.

16 likes
balasubramani's avatar

i had fixed this problem

Removed the bootstrap/cache/config.php file.

composer dumpautoload
composer update.

It's may work for you.

9 likes
schir1964's avatar

I get this error whenever I try to run composer update and don't have my Web Server and Database Server up and running.

Next

Please or to participate in this conversation.