pupadupa
pupadupa

Reputation: 1630

Laravel composer install hangs on "Installing dependencies" and consume a lot of resources (CPU, DISK)

Problem 1:

I tried install laravel 4 on my server (Ubuntu 12.04, nginx, php5-fpm) but installation hangs:

# composer install --verbose
Loading composer repositories with package information
Installing dependencies (including require-dev)

- no errors, no nothing, it's just hangs and that's all. I've tried installation using composer create-project laravel/laravel --prefer-dist ...and result was pretty the same:

Installing laravel/laravel (v4.0.9)
- Installing laravel/laravel (v4.0.9)
Loading from cache

Created project in /var/www/laravel/ex2/laravel
Loading composer repositories with package information
Installing dependencies (including require-dev)

I couldn't find any ideas/solutions.

Could anyone please tell me what is the problem and how could I fix it?

Problem 2:

@antonio-carlos-ribeiro was right, I just need to wait. But now I've got another problem:

Installation takes more than 30 minutes! And a lot of resources (CPU and DISK usage)... unbelievable amount of resources. Here is graphs of CPU and DISK read/write: Disk read/write and CPU usage I guess it's not normal behavior. Any ideas what is going on?

Thanks!

Upvotes: 15

Views: 34446

Answers (8)

Bilal Tariq
Bilal Tariq

Reputation: 649

clear composer cache

composer clear-cache

Upvotes: 0

BruceHill
BruceHill

Reputation: 7164

I was having a similar issue that Composer was hanging and leaving it for more than an hour did not help. I executed composer -vvv update and from the resulting log I saw that the requests to github were giving a response of 401, authentication failed.

I resolved it by logging into Github and generating a new OAuth token over here. I then copied the token and pasted it into this command:

composer config -g github-oauth.github.com <oauthtoken>

After executing this command, composer install then worked correctly and completed in less than a minute.

Upvotes: 5

Ricardo Gon&#231;alves
Ricardo Gon&#231;alves

Reputation: 5074

Old question, but I have found a new answer.

My php-cli did not have php-curl extension enabled.

Installing and enabling it did the trick.

Upvotes: 1

Stradlater
Stradlater

Reputation: 56

One possibility is that you have un-resolvable dependencies:

Your requirements could not be resolved to an installable set of packages.

As the others have mentioned you may need to just run composer install and wait. If the dependencies cannot be resolved, composer will scan every possible option - which may take a long time.

If you have lots of dependencies - you might want to try and remove everything from composer.json first, then add them back in one at a time to discover which ones are failing to resolve.

When composer install eventually finishes - read the output carefully, and see if there are missing dependencies you need to install manually.

In my case I was only trying to install a single package. This was my composer.json:

{
    "require-dev": {
        "phpunit/phpunit": "^8"
}

composer install took a long time to run but eventually reported:

  Problem 1
- phpunit/phpunit 8.5.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.5.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.5.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.4.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.4.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.4.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.4.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.3.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.3.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.3.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.3.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.3.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.3.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.2.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.2.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.2.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.2.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.2.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.2.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.1.6 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.1.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.1.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.1.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.1.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.1.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.1.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.0.6 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.0.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.0.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.0.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.0.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.0.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.0.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- Installation request for phpunit/phpunit ^8 -> satisfiable by phpunit/phpunit[8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.0.4, 8.0.5, 8.0.6, 8.1.0, 8.1.1, 8.1.2, 8.1.3, 8.1.4, 8.1.5, 8.1.6, 8.2.0, 8.2.1, 8.2.2, 8.2.3, 8.2.4, 8.2.5, 8.3.0, 8.3.1, 8.3.2, 8.3.3, 8.3.4, 8.3.5, 8.4.0, 8.4.1, 8.4.2, 8.4.3, 8.5.0, 8.5.1, 8.5.2].

So I installed the missing dependency - PHP extension dom:

sudo apt install php-dom

Next time I ran composer install it completed successfully.

Upvotes: 0

Militaru
Militaru

Reputation: 581

For me was composer vendor. I did just composer -vvv update

Upvotes: 10

Mohammad Wali
Mohammad Wali

Reputation: 81

I was installing it on a windows machine in xampp directory and found that it was hanged while the Apache was running and when i stopped the Apache it starts immediately and ends in some in secs.

Upvotes: 4

Gluwer
Gluwer

Reputation: 51

Make sure you are not having xdebug enabled by default. If you have, turn it off.

I had the similar problem where loading JSON dependencies took an hour (for Laravel). After turning off xdebug for cli everything loads in several seconds!

Upvotes: 3

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87719

This is Composer being slow. You need to wait for it and, yeah, it may be a lot of time.

You also can try to download the packages one by one, installing Laravel "manually"

Create your directory and enter it:

mkdir /var/www/laravel/ex2/laravel
cd /var/www/laravel/ex2/laravel

Dowload all packages ony by one:

composer require filp/whoops 1.0.7
composer require nikic/php-parser dev-master#700847e
composer require jeremeamia/superclosure 1.0.1
composer require doctrine/lexer dev-master#bc0e1f0
composer require doctrine/annotations v1.1.2
composer require doctrine/collections dev-master#bcb5377
composer require doctrine/cache v1.3.0
composer require doctrine/inflector dev-master#8b4b3cc
composer require doctrine/common dev-master#d9dea98
composer require doctrine/dbal 2.4.x-dev#9efdbce
composer require psr/log 1.0.0
composer require monolog/monolog dev-master#a501075
composer require symfony/translation 2.3.x-dev#6aedcff
composer require symfony/routing 2.3.x-dev#7d41463
composer require symfony/process 2.3.x-dev#8289810
composer require symfony/debug 2.3.x-dev#085d4fd
composer require symfony/http-foundation 2.3.x-dev#796619f
composer require symfony/event-dispatcher 2.3.x-dev#2d8ece3
composer require symfony/http-kernel 2.3.x-dev#9795c9f
composer require symfony/finder 2.3.x-dev#a175521
composer require symfony/dom-crawler 2.3.x-dev#4dc2c59
composer require symfony/css-selector 2.3.x-dev#8df20c5
composer require symfony/console 2.3.x-dev#f880062
composer require symfony/browser-kit 2.3.x-dev#7fc66ea
composer require symfony/filesystem dev-master#e558fd5
composer require swiftmailer/swiftmailer v5.0.2
composer require predis/predis 0.8.x-dev#ff004ae
composer require patchwork/utf8 v1.1.14
composer require nesbot/carbon 1.4.0
composer require ircmaxell/password-compat 1.0.x-dev#1fc1521
composer require classpreloader/classpreloader 1.0.1

Finally download Laravel

composer require laravel/framework 4.0.x-dev
composer require laravel/laravel 4.0.x

Move it to the right place

mv -f vendor/laravel/laravel/* .
mv -f vendor/laravel/laravel/.g* .
rm -rf vendor/laravel/laravel

And execute this to fix your composer.lock

composer update

After downloading the packages, Composer will cache them in your home folder, so next install you don't have to download all of them manually, unless, of course, some are updated.

Note: this is will work only for Laravel 4.0.9, since some of those packages are "marked" to download an specific commit (example: #700847e).

Upvotes: 13

Related Questions