Search code examples
symfonycomposer-phpsymfony4

Symfony deployment: error code 255 with composer install --no-dev


Here are the steps, I am following:

Cloning my repository from github

git clone https://github.com/EresDev/EresNoteSymfony.git .

Updating .env file with APP_ENV=prod

Then performing install

composer install --no-dev

I get following error:

.
.
.
  - Installing symfony/translation (v4.2.4): Loading from cache
  - Installing symfony/validator (v4.2.4): Loading from cache
  - Installing symfony/yaml (v4.2.4): Loading from cache
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 255
!!  
Script @auto-scripts was called via post-install-cmd

However, it works fine if I just use composer install without --no-dev

What can I do to make it work with --no-dev

Please refer to repository to access code if required.


Solution

  • apparently you have somehow managed to turn error display off (or it's some default). I get a very distinct error message when I run composer install --no-dev (run with commit e722218...)

    !!  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "TwigBundle" from namespace "Symfony\Bundle\TwigBundle".
    !!  Did you forget a "use" statement for another namespace? in [path]/EresNoteSymfony/src/Kernel.php:23
    !!  Stack trace:
    !!  #0 [path]/EresNoteSymfony/vendor/symfony/http-kernel/Kernel.php(424): App\Kernel->registerBundles()
    !!  #1 [path]/EresNoteSymfony/vendor/symfony/http-kernel/Kernel.php(130): Symfony\Component\HttpKernel\Kernel->initializeBundles()
    !!  #2 [path]/EresNoteSymfony/vendor/symfony/framework-bundle/Console/Application.php(65): Symfony\Component\HttpKernel\Kernel->boot()
    !!  #3 [path]/EresNoteSymfony/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 [path]/EresNoteSymfony/bin/console(38): Symfony\Component\Console\Application->run(Object(Symfony\Componen in [path]/EresNoteSymfony/src/Kernel.php on line 23
    !!  
    

    you should somehow turn error display on ;o)

    update:

    your config/bundles.php:6 says:

    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
    

    which essentially says, the twigbundle is expected in prod as well as in dev. thus the error? (but anyway, the point still stands, that you should display errors when running on cli)

    after you change that line in your bundles.php, you have to move your twig.yaml config into the dev/test folders, I suppose.