I got a problem, I tried to install a new package to my Laravel 4 project.
But when I run php composer.phar update
I get this:
Loading composer
Run composer self-update
and composer clearcache
remove vendor and composer.lock
restart your local environment and then run
php -d memory_limit=-1 /usr/local/bin/composer install
You can try setting preferred-install to "dist"
in Composer config.
If like me, you are using some micro VM lacking of memory, creating a swap file does the trick:
#Check free memory before
free -m
mkdir -p /var/_swap_
cd /var/_swap_
#Here, 1M * 2000 ~= 2GB of swap memory. Feel free to add MORE
dd if=/dev/zero of=swapfile bs=1M count=2000
mkswap swapfile
swapon swapfile
chmod 600 swapfile
#Automatically mount this swap partition at startup
echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab
#Check free memory after
free -m
As several comments pointed out, don't forget to add sudo if you don't work as root.
btw, feel free to select another location/filename/size for the file.
/var
is probably not the best place, but I don't know which place would be, and rarely care since tiny servers are mostly used for testing purposes.
If you're using docker you can use COMPOSER_PROCESS_TIMEOUT
environment:
COMPOSER_MEMORY_LIMIT: -1
COMPOSER_PROCESS_TIMEOUT: 2000 #seconds
Here's how I succeeded in installing maatwebsite\excel package from composer in Laravel Framework:
composer update
from local command prompt (then wait until all the install process finished).composer install
on remote server (then wait until all process finished).I get this problem caused for a package that don't update correctly with wildcards, I use directly the last version and it works finally.
"l3/cas-bundle": "~1.0" -------> "l3/cas-bundle": "1.1.13"