duangu4943
duangu4943
2018-10-23 05:56

运行composer update时出现内存错误

已采纳

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?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • dougekui1518 dougekui1518 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..

    点赞 评论 复制链接分享
  • donglan6777 donglan6777 3年前

    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?

    点赞 评论 复制链接分享