symfony: SF4 Deployment to Prod "Script cache:clear returned with error code 255"

Symfony version(s) affected: 4.2

Description
While deploying to production, i get following error:

# EasyDeploy installation script
| err :: Generating optimized autoload files
| out :: ocramius/package-versions:  Generating version class...
| out :: ocramius/package-versions: ...done generating version class
| err :: > post-install-cmd: @auto-scripts
| err :: Executing script cache:clear
| err :: Executed script cache:clear  [KO]
| err ::  [KO]
| err :: Script cache:clear returned with error code 255
| err :: !!  
| err :: Script @auto-scripts was called via post-install-cmd

How to reproduce Checkout the named repo and run following commands

rm -rf vendor && composer install --prefer-dist --no-interaction --no-dev --optimize-autoloader

Result:

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle".
!!  Did you forget a "use" statement for another namespace? in /Users/bjorn/code/web/wavetrophy/src/Kernel.php:33
!!  Stack trace:
!!  #0 /Users/bjorn/code/web/wavetrophy/vendor/symfony/http-kernel/Kernel.php(424): App\Kernel->registerBundles()
!!  #1 /Users/bjorn/code/web/wavetrophy/vendor/symfony/http-kernel/Kernel.php(130): Symfony\Component\HttpKernel\Kernel->initializeBundles()
!!  #2 /Users/bjorn/code/web/wavetrophy/vendor/symfony/framework-bundle/Console/Application.php(65): Symfony\Component\HttpKernel\Kernel->boot()
!!  #3 /Users/bjorn/code/web/wavetrophy/vendor/symfony/console/Application.php(145): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
!!  #4 /Users/bjorn/code/web/wavetrophy/bin/console(34): Symfony\Component\Console\Application->run(Object in /Users/bjorn/code/web/wavetrophy/src/Kernel.php on line 33
!!  
!!  Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle".
!!  Did you forget a "use" statement for another namespace? in /Users/bjorn/code/web/wavetrophy/src/Kernel.php on line 33
!!  
!!  Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle".
!!  Did you forget a "use" statement for another namespace? in /Users/bjorn/code/web/wavetrophy/src/Kernel.php on line 33
!!  
!!  Call Stack:
!!      0.1653    3944552   1. Symfony\Component\Debug\ErrorHandler->handleException(???, ???) /Users/bjorn/code/web/wavetrophy/vendor/symfony/debug/ErrorHandler.php:0
!!  
!!  
Script @auto-scripts was called via post-update-cmd

Possible Solution
No clue, sorry.

Additional context
The complete code can be found here: https://github.com/wavetrophy/wavetrophy

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 17 (5 by maintainers)

Most upvoted comments

@eldk

We fixed the bug by changing the APP_ENV variable in .env-File to: prod

For your error, it looks like your .env-File is not readable.

If you do not get any output from the console, try to set

ini_set('display_errors', '1');
error_reporting(-1);

At the top of the bin/console file. With this the console will display all errors that occur. DO NOT PUT THIS IN PROD

@D4rkMindz

You added the doctrine/doctrine-fixtures-bundle as a development requirement. While deploying you’re running composer install using the --no-dev flag.

This is not related to symfony.

Look my user environments variable (in shell terminal) :

bash-4.2$ env
POSTFIX_RELAYHOST=
APP_ENV=dev
container=oci

APP_ENV defined in your shell environment overwrite value in .env file.

APP_ENV=prod composer install --no-dev --optimize-autoloader --prefer-dist is the solution.

Hi, I have the same problem:

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!
!!  In RegisterServiceSubscribersPass.php line 69:
!!
!!    Warning: Invalid argument supplied for foreach()
!!
!!

all works well in prod env, not in dev. But my .env* files are readable.

I have an identical problem with PHP 7.2.20.

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  
!!  Fatal error: During class fetch: Uncaught ReflectionException: Class Doctrine\Bundle\FixturesBundle\Fixture not found in /var/www/src/DataFixtures/AppFixtures.php:8
!!  Stack trace:
!!  #0 /var/www/vendor/composer/ClassLoader.php(444): include('/var/www/src/Da...')
!!  #1 /var/www/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/var/www/vendor...')
!!  #2 [internal function]: Composer\Autoload\ClassLoader->loadClass('App\\DataFixture...')
!!  #3 [internal function]: spl_autoload_call('App\\DataFixture...')
!!  #4 /var/www/vendor/symfony/config/Resource/ClassExistenceResource.php(78): class_exists('App\\DataFixture...')
!!  #5 /var/www/vendor/symfony/dependency-injection/ContainerBuilder.php(353): Symfony\Component\Config\Resource\ClassExistenceResource->isFresh(0)
!!  #6 /var/www/vendor/symfony/dependency-injection/Loader/FileLoader.php(151): Symfony\Component\DependencyInjection\ContainerBuilder->getReflectionClass('App\\DataFixture...')
!!  #7 /var/www/vendor/symfony/dependency-injection/Loader/FileLoader.php(57): Symfony\Component\De in /var/www/src/DataFixtures/AppFixtures.php on line 8
!!  

The identical project but with PHP 7.2.19 works perfectly.

Linked with this problem https://github.com/symfony/symfony/issues/32395