json Composer 在更新依赖项时挂起

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32573924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 18:02:57  来源:igfitidea点击:

Composer hanging while updating dependencies

jsoncomposer-phphamcrest

提问by Chris

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

我尝试更新我今天正在使用的 Laravel 项目 composer update

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

但它挂了 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

所以我尝试了更新作曲家、转储自动加载等方法,但似乎没有任何效果。然后我以详细模式运行它:composer update -vvv

And I noticed it hung while reading this json:

我注意到它在阅读这个 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

我尝试在 packagist.org 上搜索 cordoval/hamcrest-php 并找不到它。这未在我的列表中列为依赖项composer.json

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

搜索我的供应商文件夹,我注意到mockery/mockery我使用的包 requires hamcrest/hamcrest-php,但我找不到任何引用cordoval.

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

知道出了什么问题以及如何修复它以便我可以进行更新吗?

Here's my composer.json:

这是我的 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.

我尝试从我的 composer.json 中删除一些包,包括“mockery/mockery”包。它所做的唯一更改是 Composer 将挂在不同的文件上。

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

在让 Composer 像这样运行很长时间后,它最终退出并出现如下错误:

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

Not sure what to do about that...

不知道该怎么办...

回答by Chris

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

所以事实证明问题出在php的xdebug扩展名上。在 my 中禁用它后php.ini,composer 运行没有任何问题。

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.

需要注意的是,从缓存读取文件时实际上并未发生挂断。这是作曲家试图解决依赖关系之后的一步。它只是从未完成该步骤,也从未打印输出。这就是为什么无论我做什么,它似乎总是卡在从缓存中读取文件。

回答by manuelbcd

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

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

2nd optionIf 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:

第二个选项如果这些步骤没有修复您的作曲家,那么系统可能没有足够的可用 RAM 内存(我遇到了这个问题并且症状与您描述的相同)。此时你有两个选择:

a) Increase memory (Virtual Machines or Docker) :Your container or VM needs more available memory. Follow this guide: https://stackoverflow.com/a/44533437/3518053

a)增加内存(虚拟机或 Docker):您的容器或 VM 需要更多可用内存。遵循本指南:https: //stackoverflow.com/a/44533437/3518053

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

b)生成交换文件 (Linux) :尝试创建交换文件以提供更多内存:(以上命令来自composer 在更新时杀死

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

回答by Onshop

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.

就我而言,它只是在我的 8GB ram Mac 上花费了很长时间。要检查进度并验证它是否正在通过依赖项,请在详细模式下运行 composer。这是我在问题中错过的一种方法,因此值得在此重申。

composer update -vvv

回答by Abhinav

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.

我今天遇到了同样的问题。按照建议,关闭 xdebug,但没有帮助。验证所有文件都存在。重新启动我的系统,它起作用了。

回答by Gpak

Check if you are running the minimum required php version

检查您是否正在运行所需的最低 php 版本

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

与 composer.json 文件中指定的所需 php 版本进行比较

Open terminal run

打开终端运行

php -v

php -v

Cross check in composer.json file see example below

交叉检查 composer.json 文件见下面的例子

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

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

回答by Arshad Jilani

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

回答by Rejneesh Raghunath

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

检查php.ini中[xdebug] zend_extension = "file/path"的路径

回答by Mostafa Talebi

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.

对我来说,问题出在 xDebug 上。我正在使用 IDE 的终端,调试器正在侦听传入的连接(一如既往)。关闭监听(不需要禁用扩展)解决了这个问题。

回答by EugeneGpil

I solved it by running command NOT IN VS CODE TERMINAL

我通过运行命令NOT IN VS CODE TERMINAL解决了它

回答by manix

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

我通过编辑php.ini文件来解决它,以便设置 ssl 验证所需的 de cacert:

  1. Download the file http://curl.haxx.se/ca/cacert.pem
  2. Edit php.inito 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

  1. 下载文件http://curl.haxx.se/ca/cacert.pem
  2. 编辑php.ini以设置拍拍:

    [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. 再试一次