Memory Limit for Composer Version

I need to run an update for the composer on my hosting, so I log in using ssh and try to run the command:

composer update 

inside / www folder where I have laravel and composer installation

but I get the error: enter image description here

in contact with my hosting provider, they tell me that I run the command:

 php -d memory_limit=512M composer update 

I run this command, but I get: "Could not open file: composer"

What to do? What is a soliton here?

+20
source share
6 answers

When composer update launched, the OS will look into the configured paths and try to find an executable file with this name.

When running php composer update string composer considered as a parameter for PHP, which is not performed by searches on any paths. You must provide the full path to run it.

Running which composer will tell you where the OS finds the composer's executable, and then you just use the full path in the PHP command:

 $>which composer /usr/local/bin/composer $>php -d memory_limit=512M /usr/local/bin/composer update ... 

Please note that 512 MB may be too small. My opinion is that it will gladly take 1 GB or more, depending on the number of dependencies you use and the variety of versions that you theoretically allow, i.e. if you enable Symfony ~2.3 , then you make Composer more versions than using ~2.7 .

Also note that running Composer on a production machine is not a good idea. You should have access to Github, perhaps provide access credentials, install VCS tools, and you can easily break your site if any of the remote hosting servers are down during your upgrade. It is best to use Composer in a deployment system that does all the preparation and then moves all the files to the production server.

+40
source

Install as much memory for it as you need:

 COMPOSER_MEMORY_LIMIT=-1 composer update 
+12
source

I run into problems with composer because it consumes all available memory and then the process is killed (in fact, the output message is "Killed")

So, I was looking for a solution to limit the composer's memory usage.

I tried (from @Sven answers)

 $ php -d memory_limit=512M /usr/local/bin/composer update 

But it didn’t work because

"The composer internally increases memory_limit to 1.5G."

→ That from the official site of the composer.

Then I found a command that works:

 $ COMPOSER_MEMORY_LIMIT=512M php composer.phar update 

Although 512 is not enough!

Source: https://www.agileana.com/blog/composer-memory-limit-trou troubleshooting /

+1
source

If there was enough memory, the composer would use it internally and work without problems. No need to specifically instruct the composer to do this.

You tried to increase your swap memory because it worked for me. I increased the swap memory to 4096 MB (4 GB), and now everything looks great.

First use " sudo free " to view available memory and swap memory. and configure swap as

For Debian:

 sudo fallocate -l 4G /swapfile sudo dd if=/dev/zero of=/swapfile bs=4096k count=1048 sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile 

to make this permanent, add this to the / etc / fstab file, /swapfile swap swap defaults 0 0

For CentOS:

 [ root@myserver ]:/# cd /var [ root@myserver ]:/var# touch swap.img [ root@myserver ]:/var# chmod 600 swap.img [ root@myserver ]:/var# mkswap /var/swap.img [ root@myserver ]:/var# dd if=/dev/zero of=/var/swap.img bs=4096k count=1000 [ root@myserver ]:/var# mkswap /var/swap.img [ root@myserver ]:/var# swapon /var/swap.img 

you can increase the swap volume by changing the value bs = 1024k or 2048k or 8096k depending on the size of your physical volume. use the swapon and swapoff commands to see the difference.

check for "swappiness" (60 should be fine,)

 cat /proc/sys/vm/swappiness 
+1
source

You can change the memory_limit value in your php.ini

Try increasing the limit in your php.ini file

Use -1 for unlimited or define an explicit value as 2G

 memory_limit = -1 

Note: Composer internally increases memory_limit to 1.5G.

Read getcomposer.org documentation

0
source

How big is your AWS server? If it has only 1 GB of RAM, setting a memory limit of 2 GB in php.ini will not help.

If you cannot / do not want to increase the server side to get more available RAM, you can also enable SWAP.

See here for how to enable swap. This permits 4 GB, although I usually do only 1 GB myself.

Source: taken from laracast

0
source

Source: https://habr.com/ru/post/1245394/


All Articles