Composer更新成功,但是在创建的锁定文件上Composer安装失败

时间:2019-08-13 14:46:03

标签: symfony composer-php

当我在symfony 3.4.30安装上进行作曲家更新时,它会毫无问题地完成,但是当我尝试在创建的锁定文件上运行作曲家安装时,会引发错误。

这同时在我的CentOS服务器和MacOS笔记本电脑上发生。我安装了最新的作曲家:

有人知道发生了什么事吗?

我尝试完全删除供应商目录和composer.lock文件,但均未成功。我还更新了作曲家的版本,并清除了作曲家的缓存:

composer clearcache
Cache directory does not exist (cache-vcs-dir):
Clearing cache (cache-repo-dir): /home/<user>/.composer/cache/repo
Clearing cache (cache-files-dir): /home/<user>/.composer/cache/files
Clearing cache (cache-dir): /home/<user>/.composer/cache
All caches cleared.

composer --version
Composer version 1.9.0 2019-08-02 20:55:32
php -dmemory_limit=-1 /usr/bin/composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 63 installs, 0 updates, 0 removals
  - Installing doctrine/cache (v1.8.0): Downloading (100%)
  - Installing doctrine/inflector (v1.3.0): Downloading (100%)
  - Installing paragonie/random_compat (v2.0.18): Downloading (100%)
  - Installing symfony/polyfill-php70 (v1.12.0): Downloading (100%)
  - Installing symfony/polyfill-util (v1.12.0): Downloading (100%)
  - Installing symfony/polyfill-php56 (v1.12.0): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.12.0): Downloading (100%)
  - Installing symfony/symfony (v3.4.30): Downloading (100%)
  - Installing symfony/polyfill-intl-icu (v1.12.0): Downloading (100%)
  - Installing symfony/polyfill-ctype (v1.12.0): Downloading (100%)
  - Installing symfony/polyfill-apcu (v1.12.0): Downloading (100%)
  - Installing psr/simple-cache (1.0.1): Downloading (100%)
  - Installing psr/log (1.1.0): Downloading (100%)
  - Installing psr/link (1.0.0): Downloading (100%)
  - Installing psr/container (1.0.0): Downloading (100%)
  - Installing psr/cache (1.0.1): Downloading (100%)
  - Installing twig/twig (v2.11.3): Downloading (100%)
  - Installing fig/link-util (1.0.0): Downloading (100%)
  - Installing doctrine/lexer (1.0.2): Downloading (100%)
  - Installing doctrine/annotations (v1.7.0): Downloading (100%)
  - Installing doctrine/reflection (v1.0.0): Downloading (100%)
  - Installing doctrine/event-manager (v1.0.0): Downloading (100%)
  - Installing doctrine/collections (v1.6.2): Downloading (100%)
  - Installing doctrine/persistence (1.1.1): Downloading (100%)
  - Installing doctrine/common (v2.10.0): Downloading (100%)
  - Installing doctrine/doctrine-cache-bundle (1.3.5): Downloading (100%)
  - Installing symfony/polyfill-php73 (v1.12.0): Downloading (100%)
  - Installing symfony/polyfill-php72 (v1.12.0): Downloading (100%)
  - Installing symfony/polyfill-intl-idn (v1.12.0): Downloading (100%)
  - Installing symfony/mime (v4.3.3): Downloading (100%)
  - Installing jdorn/sql-formatter (v1.2.17): Downloading (100%)
  - Installing doctrine/dbal (v2.9.2): Downloading (100%)
  - Installing doctrine/doctrine-bundle (1.11.2): Downloading (100%)
  - Installing symfony/templating (v4.3.3): Downloading (100%)
  - Installing friendsofsymfony/user-bundle (v2.1.2): Downloading (100%)
  - Installing incenteev/composer-parameter-handler (v2.1.3): Downloading (100%)
  - Installing symfony/http-client-contracts (v1.1.5): Downloading (100%)
  - Installing symfony/http-client (v4.3.3): Downloading (100%)
  - Installing sensiolabs/security-checker (v6.0.2): Downloading (100%)
  - Installing sensio/distribution-bundle (v5.0.25): Downloading (100%)
  - Installing sensio/framework-extra-bundle (v5.4.1): Downloading (100%)
  - Installing monolog/monolog (1.24.0): Downloading (100%)
  - Installing symfony/monolog-bundle (v3.4.0): Downloading (100%)
  - Installing swiftmailer/swiftmailer (v5.4.12): Downloading (100%)
  - Installing symfony/swiftmailer-bundle (v2.6.7): Downloading (100%)
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)
  - Installing ralouphie/getallheaders (3.0.3): Downloading (100%)
  - Installing psr/http-message (1.0.1): Downloading (100%)
  - Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)
  - Installing guzzlehttp/guzzle (6.3.3): Downloading (100%)
  - Installing sendgrid/php-http-client (3.9.6): Downloading (100%)
  - Installing sendgrid/sendgrid (7.3.0): Downloading (100%)
  - Installing google/recaptcha (1.2.2): Downloading (100%)
  - Installing excelwebzone/recaptcha-bundle (v1.5.15): Downloading (100%)
  - Installing sensio/generator-bundle (v3.1.7): Downloading (100%)
  - Installing symfony/phpunit-bridge (v3.4.30): Downloading (100%)
  - Installing fzaninotto/faker (v1.8.0): Downloading (100%)
  - Installing hamcrest/hamcrest-php (v2.0.0): Downloading (100%)
  - Installing mockery/mockery (1.2.3): Downloading (100%)
  - Installing doctrine/instantiator (1.2.0): Downloading (100%)
  - Installing doctrine/orm (v2.6.3): Downloading (100%)
  - Installing steevanb/doctrine-stats (1.3.3): Downloading (100%)
  - Installing steevanb/php-backtrace (2.0.1): Downloading (100%
Writing lock file
Generating autoload files
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove friendsofsymfony/user-bundle v2.1.2
    - Installation request for friendsofsymfony/user-bundle v2.1.2 -> satisfiable by friendsofsymfony/user-bundle[v2.1.2].
    - Conclusion: remove symfony/symfony v3.4.30
    - friendsofsymfony/user-bundle v2.1.2 requires symfony/templating ^2.8 || ^3.0 || ^4.0 -> satisfiable by symfony/templating[v4.3.3].
    - don't install symfony/symfony v3.4.30|remove symfony/templating v4.3.3
    - don't install symfony/templating v4.3.3|don't install symfony/symfony v3.4.30
    - Installation request for symfony/symfony v3.4.30 -> satisfiable by symfony/symfony[v3.4.30].

这是我的composer.json:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-4": {
            "AppBundle\\": "src/AppBundle"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        },
        "files": [
            "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
        ]
    },
    "require": {
        "php": ">=7.1.18",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/orm": "^2.5",
        "friendsofsymfony/user-bundle": "^2.0",
        "incenteev/composer-parameter-handler": "^2.0",
        "sensio/distribution-bundle": "^5.0.19",
        "sensio/framework-extra-bundle": "^5.0.0",
        "symfony/monolog-bundle": "^3.1.0",
        "symfony/polyfill-apcu": "^1.0",
        "symfony/swiftmailer-bundle": "^2.6.4",
        "symfony/symfony": "^3.0",
        "twig/twig": "^1.0||^2.0",
        "guzzlehttp/guzzle": "^6.3",
        "symfony/templating": "^4.1",
        "sendgrid/sendgrid": "~7",
        "excelwebzone/recaptcha-bundle": "~1.5",
        "paragonie/random_compat": "^2.0"
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0",
        "fzaninotto/faker": "~1.2",
        "mockery/mockery": "~1.1",
        "steevanb/doctrine-stats": "^1.3",
        "steevanb/php-backtrace": "^2.0"
    },
    "scripts": {
        "symfony-scripts": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ]
    },
    "config": {
        "platform": {
            "php": "7.1.18"
        },
        "sort-packages": true
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "3.4-dev"
        }
    }
}

1 个答案:

答案 0 :(得分:1)

TL; DR;

您要解决的方法是删除行

"symfony/templating": "^4.1",

从您的composer.json,然后重试整个过程。

请记住,它将把您的symfony/templating版本降级为3.4.x,并可能导致副作用。


为什么?嗯,您的问题实际上出在这里:symfony / symfony的composer.json行:https://github.com/symfony/symfony/blob/3.4/composer.json#L77

并由https://getcomposer.org/doc/04-schema.md#replace

解释

因此,实际上,当您安装symfony/symfony时,它可以代替同一版本的symfony/templating(在您的情况下为3.4.30),但是,您还可以在composer.json中获得说明,以将其安装为版本^4.3

这些行也告诉你:

- don't install symfony/symfony v3.4.30|remove symfony/templating v4.3.3
- don't install symfony/templating v4.3.3|don't install symfony/symfony v3.4.30

它实际上指示您安装symfony/symfony v3.4.30symfony/templating v4.3.3,但不能同时安装,因为replace软件包的symfony/symfony指令使其完全相同打包为symfony/templating,但与您的情况不同。

实际上,作曲家文档也准确地告诉您:

  

这对于包含子软件包的软件包也很有用,例如   例如,主要的symfony / symfony软件包包含所有Symfony   也可以单独包装的组件。如果你   需要主程序包,它将自动满足任何要求   单个组件之一,因为它替代了它们。

来源: https://getcomposer.org/doc/04-schema.md#replace