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

后端 未结 26 1414
天命终不由人
天命终不由人 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:34

    I have faced the same issue. I am on a AWS Free Microinstance which has less memory. I always try one of the below options and it always works (Before all this please check if you have the latest version of composer installed)

    sudo php -dmemory_limit=750M composer.phar update
    

    or remove the contents of the vendor folder and try composer update.

    sudo rm -rf vendor
    sudo php -dmemory_limit=750M composer.phar update --no-scripts --prefer-dist
    sudo php artisan --dump-autoload
    

    The second option tries to update all the components, if there is no update, it picks up the package from the cache else picks up from the dist

    Note: Please change the memory limit as per your choice.

    or

    Create a swap partition and try. Swap partition is the portion of the hard drive that linux uses as virtual memory when it runs out of physical memory. It's similar to the windows swap file only instead of using an actual file, linux uses a partition on the hard drive instead.

    Hope this helps

提交回复
热议问题