svanderburg / composer2nix

Generate Nix expressions to build PHP composer packages
MIT License
88 stars 25 forks source link

Fatal error: Allowed memory size of N bytes exhausted #38

Closed Sleepful closed 9 months ago

Sleepful commented 9 months ago

Hm... not sure what is going on. Any help? I suppose I need to set something like memory_limit higher, not sure how to do that. Here is the error I get:

Generating optimized autoload files
Generated optimized autoload files containing 8342 classes
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
127 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Run composer recipes at any time to see the status of your Symfony recipes.

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 134
!!
!!   // Clearing the cache for the prod environment with debug false
!!
!!
!!  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /nix/store/f0jd93dpiklzhxnq5sx8ki10ysg97327-kimai-kimai/vendor/twig/twig/src/Node/Node.php on line 158
!!
!!  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /nix/store/f0jd93dpiklzhxnq5sx8ki10ysg97327-kimai-kimai/vendor/symfony/error-handler/Error/OutOfMemoryError.php on line 1
!!  zend_mm_heap corrupted
!!
Script @auto-scripts was called via post-install-cmd
Sleepful commented 9 months ago

Oh, got it... Basically I took the same approach as https://github.com/svanderburg/composer2nix/issues/15 and mixed it with the memory_limit example in https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/php.section.md#installing-php-with-extensions-ssec-php-user-guide-installing-with-extensions and error is gone!

# default.nix
{pkgs ? import <nixpkgs> {
    inherit system;
  }, system ? builtins.currentSystem, noDev ? false, php ? pkgs.php, phpPackages ? pkgs.phpPackages}:

let
  composerEnv = import ./composer-env.nix rec {
    inherit (pkgs) stdenv lib writeTextFile fetchurl unzip;
    php =
      pkgs.php.buildEnv {
        extensions = ({ enabled, all }: enabled ++ (with all; [
          mbstring gd intl pdo tokenizer zip xsl
        ]));
        extraConfig = "memory_limit=256M";
      };
    phpPackages = php.packages;
  };
in
import ./php-packages.nix {
  inherit composerEnv noDev;
  inherit (pkgs) fetchurl fetchgit fetchhg fetchsvn;
}