首页 > 解决方案 > Composer 更新正在尝试删除根包

问题描述

我正在尝试安装 3 个包,其中 1 个是我在 GitHub 上分叉的。安装失败,错误消息说删除根包和我所在的 git 分支(开发),这没有任何意义。

我尝试了什么:

总之,在一个空白项目上它可以正常工作,但不能在我的其他项目(esynaps/api-v2.e-synaps.com)上工作。

错误信息:

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

  Problem 1
    - don't install elasticsearch/elasticsearch 5.0.x-dev|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.0.0|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.1.0|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.1.1|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.1.2|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.1.3|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.2.0|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.3.0|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.3.1|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.3.2|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.3.2|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.3.1|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.3.0|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.2.0|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.1.3|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.1.2|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.1.1|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.1.0|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch v5.0.0|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch 5.3.3|remove esynaps/api-v2.e-synaps.com dev-develop
    - don't install elasticsearch/elasticsearch 5.0.x-dev|remove esynaps/api-v2.e-synaps.com dev-develop
    - Installation request for esynaps/api-v2.e-synaps.com dev-develop -> satisfiable by esynaps/api-v2.e-synaps.com[dev-develop].
    - Installation request for elasticsearch/elasticsearch ^5.0 -> satisfiable by elasticsearch/elasticsearch[5.0.x-dev, v5.0.0, v5.1.0, v5.1.1, v5.1.2, v5.1.3, v5.2.0, v5.3.0, v5.3.1, v5.3.2, 5.3.3].

这是空白项目的composer.json:

{
"name": "project/test",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
    {
        "name": "my name",
        "email": "my@email.com"
    }
],
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/esynaps/elasticsearch-php"
    }
],
"require": {
    "ongr/elasticsearch-bundle": "^5.0",
    "ongr/elasticsearch-dsl": "^5.0",
    "elasticsearch/elasticsearch": "^5.0"
}
"replace": {
    "elasticsearch/elasticsearch": "dev-master"
}
}

分叉链接:https ://github.com/esynaps/elasticsearch-php

这是目标项目的composer.json:

{
"name": "esynaps/api-v2.e-synaps.com",
"license": "proprietary",
"type": "project",
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
    "psr-4": {
        "": "src/"
    },
    "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"
    ]
},
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/esynaps/elasticsearch-php"
    },
    {
        "type": "vcs",
        "url": "https://github.com/esynaps/neo4j-php-ogm"
    },
    {
        "type": "vcs",
        "url": "https://github.com/angelov/neo4j-symfony"
    }
],
"require": {
    "php": ">=7.1",
    "akeneo/spreadsheet-parser": "^1.2",
    "beberlei/DoctrineExtensions": "^1.0",
    "box/spout": "^2.7",
    "c0de8/matchmaker": "^2.0",
    "defuse/php-encryption": "^2.1",
    "doctrine/doctrine-bundle": "^1.6",
    "doctrine/orm": "^2.5",
    "friendsofsymfony/rest-bundle": "^2.2",
    "graphaware/neo4j-php-ogm": "dev-master",
    "incenteev/composer-parameter-handler": "^2.0",
    "jms/serializer-bundle": "^1.1",
    "justinrainbow/json-schema": "^5.2",
    "nelmio/api-doc-bundle": "dev-master",
    "nelmio/cors-bundle": "^1.5",
    "neo4j/neo4j-bundle": "dev-method-reset",
    "ongr/elasticsearch-bundle": "5.*",
    "ongr/elasticsearch-dsl": "5.*",
    "elasticsearch/elasticsearch": "5.*",
    "phpdocumentor/reflection-docblock": "*",
    "phpoffice/phpexcel": "^1.8",
    "piwik/device-detector": "^3.7",
    "ptrofimov/matchmaker": "*",
    "sensio/distribution-bundle": "^5.0.19",
    "sensio/framework-extra-bundle": "^5.0",
    "symfony/monolog-bundle": "^3.1.0",
    "symfony/polyfill-apcu": "^1.0",
    "symfony/swiftmailer-bundle": "^2.3.10",
    "symfony/symfony": "3.*",
    "twig/twig": "^1.0||^2.0"
},
"require-dev": {
    "behat/behat": "^3.3",
    "behat/mink": "^1.7",
    "behat/mink-browserkit-driver": "^1.3",
    "behat/mink-extension": "^2.2",
    "behat/mink-selenium2-driver": "^1.3",
    "behat/symfony2-extension": "^2.1",
    "phpunit/phpunit": "^6.3",
    "sensio/generator-bundle": "^3.0",
    "symfony/phpunit-bridge": "^3.3"
},
"replace": {
    "elasticsearch/elasticsearch": "dev-master"
},
"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"
    ],
    "test": "phpunit",
    "assets": "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets"
},
"config": {
    "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": null
}
}

$ php -v

PHP 7.1.7 (cli) (built: Jul  6 2017 16:51:52) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.7, Copyright (c) 1999-2017, by Zend Technologies

$作曲家-v

Composer 版本 1.6.5 2018-05-04 11:44:59

标签: phpsymfonyelasticsearchcomposer-php

解决方案


感谢rob006的帮助。只需删除 composer.json 中的“替换”属性。这个属性的效用被误解了。

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

列出被此包替换的包。这允许你分叉一个包,以不同的名称和它自己的版本号发布它,而需要原始包的包继续使用你的分叉,因为它替换了原始包。


推荐阅读