C
C
Cat Anton2021-10-25 19:38:34
Composer
Cat Anton, 2021-10-25 19:38:34

How to resolve dev dependencies in composer?

There are three internal repositories: core and two dependencies AAA and BBB.

company/core composer.json:

{
    "name": "company/core",
    "require": {
        "company/aaa": "1.9.3",
        "company/bbb": "1.4.0"
    },
    "config": {
        "discard-changes": true
    },
    "autoload": { ... },
    "repositories": [ ... ]
}


company/aaa composer.json:
{
    "name": "company/aaa",
    "minimum-stability": "dev",
    "require": { ... },
    "autoload": { ... }
}


company/bbb composer.json:
{
    "name": "company/bbb",
    "prefer-stable": true,
    "require": {
        "company/aaa": ">=1.8.0"
    },
    "autoload": { ... },
    "repositories": { ... }
}


We want to temporarily connect the my_branch_name dev branch to core, but we get an error:
$ composer require "company/aaa:dev-my_branch_name"

./composer.json has been updated
Running composer update company/aaa
Loading composer repositories with package information                                                                                                                 Updating dependencies                                 
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - company/bbb is locked to version v1.4.0 and an update of this package was not requested.
    - company/bbb v1.4.0 requires company/aaa >=1.8.0 -> found company/aaa[dev-master, v1.8.0, ..., v1.9.6] but it conflicts with your root composer.json require (dev-my_branch_name).

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.


The flag -Wdoesn't help. Tell me what you need to explain to the composer in order to do what you have planned? We can change all three composer files.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Gordinskiy, 2021-10-25
@DmitriyGordinskiy

What about this crutch:

composer require "company/aaa:dev-my_branch_name as 1.8.1"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question