January 08, 2016

How to Fix ‘Command “clear-compiled” is not defined’ Error When Upgrading to Laravel 5.2

While trying to upgrade my production app from Laravel 5.1 to 5.2 via composer, I encountered this error message:

Generating autoload files
> php artisan clear-compiled

  Command "clear-compiled" is not defined.

Script php artisan clear-compiled handling the post-install-cmd event returned with an error

  Error Output:

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs]

This is unexpected because I did not have any error in my local development environment. Some digging around shows that this has been a long standing bug. But the work around is very easy.


Go to your Laravel’s project directory and clear out your caches as followed, and everything will work smoothly again!

$ rm -Rf bootstrap/cache/*

Hello! My name is Jian Jye and I work on Laravel projects as my main job. If my article was helpful to you, a shoutout on Twitter would be awesome! I'm also available for hire if you need any help with Laravel. Contact me.