Composer hanging while updating dependencies
Asked Answered
I

16

67

I tried updating a Laravel project I'm working on today using composer update

But it hung on Updating dependencies (including require-dev)

So I tried things like updating composer, dump-autoload, but nothing seemed to work. Then I ran it in verbose mode: composer update -vvv

And I noticed it hung while reading this json:

Reading path/to/Composer/repo/https---packagist.org/provider-cordoval$hamcrest-php.json from cache

I tried searching for cordoval/hamcrest-php on packagist.org and couldn't find it. This isn't listed as a dependency in my composer.json

Searching through my vendor folder, I notice the mockery/mockery package I use requires hamcrest/hamcrest-php, but I can't find anything that makes any reference to cordoval.

Any idea what's wrong and how I can fix it so that I can do the update?

Here's my composer.json:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "laravel/framework": "4.2.*",
        "iron-io/iron_mq": "dev-master",
        "phpunit/phpunit": "4.2.*",
        "mockery/mockery": "dev-master",
        "xethron/migrations-generator": "dev-master",
        "mailgun/mailgun-php": "dev-master"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
}

Update

I've tried removing some of the packages from my composer.json, including the "mockery/mockery" package. The only change it made was that Composer would hang on a different file.

After leaving Composer running like that for quite a long time, it finally exited with an error such as the following:

/path/to/ComposerSetup/bin/composer: line 18:  1356 Segmentation fault      php "${dir}/composer.phar" $*

Not sure what to do about that...

Ilke answered 14/9, 2015 at 21:4 Comment(4)
What does your composer.json look like? Did you try doing a composer self-update before?Sidman
yep, I tried the self-update. I've updated my question with the composer.jsonIlke
You can run composer diagnose to check if you have any connectivity issuesHomogamy
Thanks, I didn't know about that. composer diagnose gave me a few pointers to improve my composer.json, but nothing it suggested changed the problem.Ilke
I
53

So it turns out the problem was with php's xdebug extension. After disabling it in my php.ini, composer ran without any problems.

And just to note, the hang-up wasn't actually occurring while reading files from the cache. It was the step right after where composer was trying to resolve dependencies. It just never finished that step and never printed the output. That's why no matter what I did, it always appeared to be stuck reading a file from the cache.

Ilke answered 20/9, 2015 at 16:20 Comment(3)
If you don't know why it's hanging try 'composer diagnose' cmdArarat
I switch my network from wifi to mobile, maybe it's cached at router, strange but it helpedObligato
for me it was intellij listening on the debug port that caused the issue - closing the intellij project let composer update properly.Collator
T
102

In my case, it was simply taking a very long time on my 8GB ram Mac. To check the progress and verify that it is going through the dependencies, run composer in verbose mode. This was an approach I missed in the question so worth re-stating here.

composer update -vvv
Ticklish answered 4/2, 2020 at 22:31 Comment(4)
This was the solution for me, it just takes a while without giving any output on what it's doing. Thus thinking that it stalls might be true in that case.Ossification
The best approach , as we will know what went wrong !Faber
Thank you. This one really make sense.Argolis
For some reason composer, unlike pip, downloads whole package lists, which can take a long time.Toulon
I
53

So it turns out the problem was with php's xdebug extension. After disabling it in my php.ini, composer ran without any problems.

And just to note, the hang-up wasn't actually occurring while reading files from the cache. It was the step right after where composer was trying to resolve dependencies. It just never finished that step and never printed the output. That's why no matter what I did, it always appeared to be stuck reading a file from the cache.

Ilke answered 20/9, 2015 at 16:20 Comment(3)
If you don't know why it's hanging try 'composer diagnose' cmdArarat
I switch my network from wifi to mobile, maybe it's cached at router, strange but it helpedObligato
for me it was intellij listening on the debug port that caused the issue - closing the intellij project let composer update properly.Collator
C
29

1st of all : Check firewall and proxy connections. If everything is ok but composer is still hanging try to clear composer cache:

composer clear-cache

https://getcomposer.org/doc/03-cli.md#clear-cache

2nd option If these steps does not repair your composer then it's possible that the system does not have enough RAM memory available (I faced this problem and the symptomps were the same that you describe). At this point you have two options:

a) Increase memory (Virtual Machines or Docker) : Your container or VM needs more available memory. Follow this guide: https://mcmap.net/q/126678/-how-to-assign-more-memory-to-docker-container

b) Generate swap file (Linux) : Try creating a swap file to provide more memory: (Above commands are from composer killed while updating)

free -m
mkdir -p /var/_swap_
cd /var/_swap_
#Here, 1M * 2000 ~= 2GB of swap memory
dd if=/dev/zero of=swapfile bs=1M count=2000
mkswap swapfile
swapon swapfile
chmod 600 swapfile
echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab
#cat /proc/meminfo
free -m
Commixture answered 30/6, 2017 at 10:41 Comment(2)
I always have to come back to this answer a every few weeks and the composer clear-cache works for me everytime.Directional
That is fine @JaredDunham. The other workaround is useful for the rare cases when 1st option does not work. Actually I faced that problem one time working with an undersized VM.Commixture
L
21

Some times it is stuck because it is trying to use HTTP instead of https so just run this

composer config --global repo.packagist composer https://packagist.org
Lit answered 23/7, 2020 at 9:46 Comment(1)
OMG 😳️ Where were you all these times? I don't know why it worked. I tried composer require -vvv package_name without the above command but I saw it was using https. But I'm shocked there was literally no difference in those two commands.Gideon
D
4

Working for me. First Run command for auto load, then clear cache and run update.

composer dump-autoload
php artisan cache:clear
php artisan view:clear
composer update
Dialect answered 8/2, 2019 at 6:58 Comment(0)
M
4

For me the issue was with xDebug. I was using IDE's terminal, and the debugger was listening to incoming connections (as always). Turning the listening off (without requiring to disable the extension) solved the issue.

Mediant answered 22/12, 2019 at 7:44 Comment(0)
B
3

this worked for me:

composer self-update
Bragi answered 30/11, 2020 at 9:50 Comment(0)
S
2

I solved it by running command NOT IN VS CODE TERMINAL

Simonesimoneau answered 24/1, 2020 at 7:17 Comment(0)
S
2

I found this in another article, I found that doing the following below worked. It seemed to be a cache/download issue into the composer packages cache.

composer update -vvv

Then doing the following: Add or edit your composer file to have these settings.

"repositories": [
    {
         "type": "composer", 
         "url": "https://packagist.org"
    },
    { "packagist": false }
]
Selfeffacement answered 17/6, 2020 at 9:3 Comment(0)
U
1

Restart your system.

I faced the same problem today. Going by advice, turned off xdebug, but did not help. Verified all files were present. Restarted my system, and it worked.

Unlock answered 12/10, 2017 at 7:6 Comment(1)
Do you mean you gracefully rebooted the entire server?Cheops
S
1

Check if you are running the minimum required php version

Compare with the specified required php version in the composer.json file

Open terminal run

php -v

Cross check in composer.json file see example below

"require": { "php": "^7.1.3", }

Samalla answered 6/10, 2018 at 5:25 Comment(0)
E
1

check the path of [xdebug] zend_extension = "file/path" in php.ini

Excellence answered 10/2, 2019 at 19:2 Comment(0)
B
0

I solved it by editing php.ini file in order to set de cacert required for ssl verification:

  1. Download the file http://curl.haxx.se/ca/cacert.pem
  2. Edit php.ini to set the pat:

    [openssl]
    ; The location of a Certificate Authority (CA) file on the local filesystem
    ; to use when verifying the identity of SSL/TLS peers. Most users should
    ; not specify a value for this directive as PHP will attempt to use the
    ; OS-managed cert stores in its absence. If specified, this value may still
    ; be overridden on a per-stream basis via the "cafile" SSL stream context
    ; option.
    openssl.cafile=C:\web\certs\cacert.pem
    curl.cainfo=C:\web\certs\cacert.pem
    
  3. Try again

Balkin answered 7/1, 2020 at 23:39 Comment(3)
Sounds insecure to be downloading your certs from Swedish hackers.Blackmail
This particular swedish hacker is the creator of cURL. If we can't trust him, we can't trust anything on the internet :PHomochromatic
@IsakBerglind TIL cURL is just stealing my credit card information to buy skins on Valorant.Fritter
W
0

Personally, I discovered using free that my system had 0kb of swap storage. Creating a 1GB swap file using https://linuxize.com/post/create-a-linux-swap-file/ solved the problem instantly.

Wetnurse answered 19/1, 2022 at 16:7 Comment(1)
Please do not duplicate existing answersTricotine
H
0

My problem solved with: Change the wifi (I use my phone) - Waiting (about 5 minutes) Here is the output.

Creating a "magento/project-community-edition" project at "/tmp/exampleproject"
Installing magento/project-community-edition (2.4.5-p1)
  - Installing magento/project-community-edition (2.4.5-p1): Loading from cache
Created project in /tmp/exampleproject
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies (including require-dev)

After waiting I saw the following output:

Updating dependencies (including require-dev)
Package operations: 546 installs, 0 updates, 0 removals
  - Installing laminas/laminas-dependency-plugin (2.4.0): Loading from cache

Not sure what is the reason but I also run the following commands.

To diagnose the problem you should run the following:

composer diagnose

If you get OK from each line (it should be a warning but not important I had to), That means there is no problem with the composer. Try to switch wifi and do not forget to wait!!!

Hofer answered 29/12, 2022 at 10:5 Comment(0)
C
0

This situation also arises if you have a github access token configured that is expired.

This command

composer config -g github-oauth.github.com

will show you if you have an access token configured.

To renew the access token, log into GitHub, go to settings, then select developer settings and finally Personal access tokens. Here you can renew an expired token or create a new one.

You can then update your token as follows:

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

Colis answered 10/4 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.