Report this

What is the reason for this report?

Running 'composer update' hangs

Posted on November 27, 2019

I’ve got a Laravel based project that I’m updating to version 5.6. To do so I need to update some PHP packages with composer.

When I run ‘composer update’ after making the changes to composer.json, it just hangs - nothing else prints and the command does not complete.

So far ony my most recent run it’s been 20 mins and no response. Usually it takes under 1 minute, and gives feedback immediately.

I’ve had a similar problem very rarely before where there was not enough memory available and I had to create a swap file. I checked, and the swap file is still there and has 2+ GB of space free.

Any other suggestions?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Oh yeah, I’ve also already run composer clear-cache

If your composer update command is hanging and taking unusually long to complete in your Laravel project, this can indeed be frustrating. Here are several strategies and checks you can perform to diagnose and possibly resolve the issue:

1. Check Composer Version

Ensure you are using the latest version of Composer, as updates often include performance improvements and bug fixes:

composer self-update

2. Increase Composer’s Memory Limit

Even though you mentioned having sufficient swap space, it’s often beneficial to explicitly allow Composer to use more memory. This can be especially useful on systems where PHP’s memory limit is globally set to a conservative value:

COMPOSER_MEMORY_LIMIT=-1 composer update

Setting COMPOSER_MEMORY_LIMIT=-1 allows Composer to use unlimited memory. If you are concerned about potential out-of-memory problems, specify a large but finite amount like 2G or 4G.

3. Check for Network Issues

Composer relies on external connections to fetch package information. A slow or unreliable network connection can cause Composer to hang:

  • Run ping packagist.org to check if there’s a network latency or packet loss issue.
  • If you are behind a proxy, make sure your proxy settings are configured correctly in your environment or Composer config.

4. Use Composer Diagnostics

Composer has a diagnostic tool to check common errors:

composer diagnose

This command checks for potential issues with your Composer setup.

5. Verbose Output and Profile

Running the update command with verbose output or profiling can provide more insight into where Composer might be hanging:

composer update --verbose

Or to see performance profiling:

composer update --profile

6. Disable Plugins

Sometimes, Composer plugins can interfere with the update process. Try running Composer without plugins:

composer update --no-plugins

8. Check for Deadlocks in Scripts

If you have any custom scripts in your composer.json (e.g., scripts that run pre- or post-update), ensure these scripts are not causing a deadlock or waiting indefinitely for an external resource.

9. Temporarily Reduce the Number of Dependencies

If the problem persists, consider updating packages one by one or in smaller groups to isolate the problematic dependency if any.

10. Check System Monitoring Tools

Look at tools like top or htop on Linux to see if Composer is actively using CPU or if it’s stuck waiting for I/O operations. This can give you a clue whether the process is actively working or merely hanging.

11. Update Dependencies Individually

Sometimes, conflicts between packages can cause Composer to hang while solving dependencies. Try updating dependencies one at a time to isolate any conflicts:

composer require some/package

By following these steps, you should be able to better understand why composer update is hanging and hopefully resolve the issue. If the problem is particularly persistent, consider breaking down your composer.json to simpler forms and gradually build up to identify the problematic configuration or package.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.