skip to Main Content

I am trying to deploy a Sylius app to Heroku. While doing the build process fails with following error:

...

remote:          - Installing doctrine/doctrine-migrations-bundle (2.1.2): Loading from cache
remote:          - Installing doctrine/doctrine-fixtures-bundle (v2.4.1): Loading from cache
remote:          - Installing sylius/sylius (v1.6.4): Loading from cache
remote:          - Installing symfony/dotenv (v4.4.1): Loading from cache
remote:        Generating optimized autoload files
remote:        ocramius/package-versions:  Generating version class...
remote:        ocramius/package-versions: ...done generating version class
remote:        Executing script cache:clear [KO]
remote:         [KO]
remote:        Script cache:clear returned with error code 1
remote:        !!
remote:        !!   // Clearing the cache for the prod environment with debug
remote:        !!   // false
remote:        !!
remote:        !!  PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /tmp/build_f92eb0b1353ebcf9e35e6d53f7853796/vendor/twig/twig/src/Node/Node.php on line 168
remote:        !!  PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in /tmp/build_f92eb0b1353ebcf9e35e6d53f7853796/vendor/composer/ClassLoader.php on line 444
remote:        !!
remote:        Script @auto-scripts was called via post-install-cmd
remote:
remote:  !     ERROR: Dependency installation failed!
remote:  !
remote:  !     The 'composer install' process failed with an error. The cause
remote:  !     may be the download or installation of packages, or a pre- or
remote:  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote:  !     in your 'composer.json'.
remote:  !
remote:  !     Typical error cases are out-of-date or missing parts of code,
remote:  !     timeouts when making external connections, or memory limits.
remote:  !
remote:  !     Check the above error output closely to determine the cause of
remote:  !     the problem, ensure the code you're pushing is functioning
remote:  !     properly, and that all local changes are committed correctly.
remote:  !
remote:  !     For more information on builds for PHP on Heroku, refer to
remote:  !     https://devcenter.heroku.com/articles/php-support
remote:
remote:  !     Push rejected, failed to compile PHP app.

I have already tried everything that suggested from Heroku’s documentation to increase the memory limit https://devcenter.heroku.com/articles/php-concurrency#tuning-concurrency-using-memory_limit

But no of the suggested methods changes the memory limit and it remains at 128M, see error: Allowed memory size of 134217728 bytes exhausted

  • located user.init with content memory_limit = 256M at the root document. In my case /public

  • located fpm_costum.conf with content php_value[memory_limit] = 256M at the root document and the top level folder, as changing the Procfile to:
    web: heroku-php-apache2 /public -F fpm_custom.conf

I am out of ideas…

2

Answers


  1. This happens because your limit is not propagated to the cache:clear script which gets executed as a post script. Try using the COMPOSER_MEMORY_LIMIT env variable instead:

    COMPOSER_MEMORY_LIMIT=512M composer install …
    

    Make sure you don’t overwrite this limit inside the public/index.php file. This was the mistake I made some time ago…

    Be aware, couple more packages and soon you will have to increase this value up to a gig. Sylius eats lots of RAM.

    Login or Signup to reply.
  2. Composer also respects a memory limit defined by the COMPOSER_MEMORY_LIMIT environment variable:

    COMPOSER_MEMORY_LIMIT=-1 composer update
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search