【问题标题】:Composer update is trying to remove the root packageComposer 更新正在尝试删除根包
【发布时间】:2023-03-30 16:28:01
【问题描述】:

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

我尝试了什么:

  • 删除 composer.lock
  • 删除供应商文件夹
  • 执行 composer clearcache 命令
  • 尝试一个空白项目:它可以工作

总之,在一个空白项目上它可以正常工作,但在我的其他项目(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

【问题讨论】:

  • 您是否尝试过删除 composer.lock 以及供应商文件夹并进行全新的 composer 安装?锁文件会导致这种事情
  • 对不起,我忘了说:是的,我还删除了 composer.lock
  • 你的 PHP 版本是多少(显示php -v 的结果)?你想用这个replace 配置实现什么?
  • $ 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,版权所有 (c) 1998-2017 Zend Technologies 和 Zend OPcache v7.1.7,版权所有 (c) 1999-2017,Zend Technologies
  • 感谢您让我走上正轨。我从我的项目(api-v2)中删除了“替换”对象,它似乎有效。当我昨天尝试时,我遇到了冲突,我添加了替换,但我没有更多了。如果您希望我将其标记为已接受,请发布答案。

标签: php symfony elasticsearch composer-php


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-28
    • 2020-03-04
    • 2018-03-25
    • 1970-01-01
    • 1970-01-01
    • 2017-01-02
    • 1970-01-01
    • 2015-03-12
    相关资源
    最近更新 更多