Search code examples
laravellaravel-forge

Laravel Forge deploy errors from Composer update


My application works fine locally and is running on Digital Ocean. But I am getting the following two alternate deploy errors on Laravel Forge.

If I run:

composer update --no-dev
php artisan optimize

then I get the following error on Forge:

[RuntimeException]
The lock file does not contain require-dev information, run install with the --no-dev option or run update to install those packages.

If I run:

composer update
php artisan optimize

then I get this on Forge:

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
PHP Fatal error:  Call to undefined method
Illuminate\Foundation\Application::getCachedCompilePath() in /home/forge/default/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php on line 28
PHP Stack trace:
PHP   1. {main}() /home/forge/default/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /home/forge/default/artisan:36
PHP   3. Symfony\Component\Console\Application->run() /home/forge/default/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:94
PHP   4. Symfony\Component\Console\Application->doRun() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:126
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:195
PHP   6. Illuminate\Console\Command->run() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:874
PHP   7. Symfony\Component\Console\Command\Command->run() /home/forge/default/vendor/laravel/framework/src/Illuminate/Console/Command.php:101
PHP   8. Illuminate\Console\Command->execute() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
PHP   9. Illuminate\Container\Container->call() /home/forge/default/vendor/laravel/framework/src/Illuminate/Console/Command.php:115
PHP  10. call_user_func_array:{/home/forge/default/storage/framework/compiled.php:925}() /home/forge/default/storage/framework/compiled.php:925
PHP  11. Illuminate\Foundation\Console\ClearCompiledCommand->fire() /home/forge/default/storage/framework/compiled.php:925

[Symfony\Component\Debug\Exception\FatalErrorException]                             
Call to undefined method Illuminate\Foundation\Application::getCachedCompilePath()
Script php artisan clear-compiled handling the post-install-cmd event returned with an error

[RuntimeException
Error Output: PHP Fatal error:  Call to undefined method Illuminate\Foundation\Application::getCachedCompilePath() in /home/forge/default/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php on line 28  
PHP Stack trace:                                                                                                                                                                                                                          
PHP   1. {main}() /home/forge/default/artisan:0                                                                                                                                                                                           
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /home/forge/default/artisan:36                                                                                                                                                    
PHP   3. Symfony\Component\Console\Application->run() /home/forge/default/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:94                                                                                        
PHP   4. Symfony\Component\Console\Application->doRun() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:126                                                                                          
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:195                                                                                   
PHP   6. Illuminate\Console\Command->run() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:874                                                                                                       
PHP   7. Symfony\Component\Console\Command\Command->run() /home/forge/default/vendor/laravel/framework/src/Illuminate/Console/Command.php:101                                                                                             
PHP   8. Illuminate\Console\Command->execute() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257                                                                                               
PHP   9. Illuminate\Container\Container->call() /home/forge/default/vendor/laravel/framework/src/Illuminate/Console/Command.php:115                                                                                                       
PHP  10. call_user_func_array:{/home/forge/default/storage/framework/compiled.php:925}() /home/forge/default/storage/framework/compiled.php:925                                                                                           
PHP  11. Illuminate\Foundation\Console\ClearCompiledCommand->fire() /home/forge/default/storage/framework/compiled.php:925

What am I doing wrong?


Solution

  • probably the easiest thing to do here is this.

    1. in your local development environment double check your composer.json file for any items in the "require" section which should be in the "require-dev" section and move them if need be
    2. Delete your local composer.lock file
    3. Run composer install composer update -vvv
    4. Test your application locally
    5. When satisfied that everything is working in line with your expectations commit your composer.lock file back to your version control system and redeploy the application on Forge

    If you continue to get errors on deploy and there is nothing else of worth on the server I'd destroy your old server instance then create a new server on Forge. Have it run the build with the new composer.lock file and I'm sure it will get you past this issue. :-D

    On another note which may help, generally on deployment I'll favour composer install over composer update on the basis I'll have tested functionality based on specific versions of dependencies which are recorded in the composer.lock file. Following that approach means application behaviour should be more predictable. You'll risk encoutering unpredictable behaviour where you or one of your dependencies relies on a library which is always the latest version (e.g. dev-master) since the code could be changing very frequently.