PHP Composer update “cannot allocate memory” error (using Laravel 4)

后端 未结 26 1368
天命终不由人
天命终不由人 2020-11-29 14:46

I just can\'t solve this one.

I\'m on Linode 1G RAM basic plan. Trying to install a package via Composer and it\'s not letting me. My memory limit is set to \"-1\" o

相关标签:
26条回答
  • 2020-11-29 15:13

    A bit old but just in case someone new is looking for a solution, updating your PHP version can fix the issue.

    Also you should be committing your composer.lock file and doing a composer install on a production environment which is less resource intensive.

    More details here: https://github.com/composer/composer/issues/1898#issuecomment-23453850

    0 讨论(0)
  • 2020-11-29 15:13

    Please disable js bundling and increase memory. That should fix it. I fixed mine by disabling js bundling.

    Thanks

    0 讨论(0)
  • 2020-11-29 15:14

    I had a similar issue on the cheapest server (512MB RAM) hosted with DigitalOcean, and I was also running Jenkins CI on the same server. After I stopped the Jenkins instance the composer install command worked (well, to a point, it failed with the mcrypt extension missing besides already being installed!).

    Maybe if you have another app running on the server, maybe its worth trying to stop it and re-running the command.

    0 讨论(0)
  • 2020-11-29 15:17

    Try this:

    /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
    /sbin/mkswap /var/swap.1
    /sbin/swapon /var/swap.1
    

    This work for me on Centos 6

    0 讨论(0)
  • 2020-11-29 15:19

    I get into this situation most of the times so normally i used to follow the step of setting the swap memory.

    But now i found a simple alternate trick which worked for me.

    Run composer update --no-dev Other than composer update

    0 讨论(0)
  • 2020-11-29 15:21

    Looks like you runs out of swap memory, try this

    /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
    /sbin/mkswap /var/swap.1
    /sbin/swapon /var/swap.1
    

    as mentioned by @BlackBurn027 on comments below, this solution was described in here

    0 讨论(0)
提交回复
热议问题