2

Error:

Updating vlucas/phpdotenv (v2.4.0 => v2.5.1): The following exception is caused by a lack of memory or swap, or not having swap configured Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

Currently the AWS Instance RAM: 2GB

Though we have fixed the issue by upgrading RAM from 2GB => 4GB but I have few doubts as increasing RAM this should not be the solution for a small site.

Could you please check the following points:

1) What is the recommended memory required by Laravel for updating the packages (composar.phar update)?

2) Does laravel use SWAP memory as well while composer update?

Dave
  • 3,073
  • 7
  • 20
  • 33
user2557649
  • 93
  • 1
  • 8

2 Answers2

3

I had the same problem and never found the reason. You could run composer update --profile or even composer update --profile -vvv to have a detailed list of what's going on under the hood. The first one will show you how much memory is used.

It shouldn't be over 600Mb. But still you will run out of memory. As the laravel app goes into maintenance mode, it shouldn't add to it. You could run in a second shell the command top -ac and see what happens there.

The hosting company couldn't help me either as they blamed it on me lol.

But there is a way around. Upload the composer.lock only and on the production server run composer install --no-dev. It will give you a warning about outdated packages. Answer 'yes' and your prod server will be updated without a glitch. This command runs the laravel composer.json scripts commands too and updates the composer.json package versions..

Dimitri Mostrey
  • 2,302
  • 1
  • 12
  • 11
  • We can try this also, this solved the problem ---------------------------------------------------- /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 /sbin/mkswap /var/swap.1 /sbin/swapon /var/swap.1 ---------------------------------------------------- – user2557649 Oct 31 '18 at 11:28
  • IF you run into an error (something not found), I had this last week. Run `composer dump-autoload` and the error vanishes. – Dimitri Mostrey Dec 12 '18 at 09:56
2

Ideally, composer update is only run on your development environment, when you push your code in AWS server, the command you must use is composer install (which doesn't use too much memory).

If you want to know the difference between update or install, refer to this link: What are the differences between composer update and composer install?

aceraven777
  • 4,358
  • 3
  • 31
  • 55
  • Hi, Thanks for your reply. Composer update on the development server and composer install is fine for the first time deployment. But for the next couple of deployments, we have to run composer update means again it will create the issue. Or we have to update the vendor everytime which are quite heavy. – user2557649 Oct 23 '18 at 09:56
  • For the next couple of deployments, ideally you have to always run `composer update` on your development before deploying to your AWS server, push you code in the server, then in your server you run `composer install`. Kindly read my link above, seems that you don't understand the function of `composer install` and `composer update`. – aceraven777 Oct 23 '18 at 10:34
  • It doesn't mean that `composer install` is only run on the first time of deployment. – aceraven777 Oct 23 '18 at 10:39