composer / composer/satis

Enabling "providers" breaks "replace" for packages from other repositories

Open
#534 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
3.3k
Forks
530
Avg merge
6h 53m
Merged PRs (30d)
13

Description

Related to #367 (#371 has only fixed replacing within the same repository).

### Repro steps

1. create _satis.json_
```json
{
"name": "acme/satis",
"homepage": "http://localhost:8080/",
"require-all": true,
"repositories": [
{
"type": "package",
"package": {
"name": "acme/phpunit",
"version": "7.5.8.0",
"dist": {
"type": "file",
"url": "https://phar.phpunit.de/phpunit-7.5.8.phar"
},
"replace": {
"phpunit/phpunit": "self.version"
}
}
}
]
}
```
2. run satis build
3. create a test project with the following _composer.json_
```json
{
"name": "acme/project",
"repositories": [
{"type": "composer", "url": "http://localhost:8080/"}
],
"require": {
"kuria/phpunit-extras": "^2.0.3",
"acme/phpunit": "^7.5"
},
"config": {
"secure-http": false
}
}
```
4. run `composer update`
This works as expected. The _acme/phpunit_ package is pulled instead of _phpunit/phpunit_, which is a dependency of _kuria/phpunit-extras_.

```
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
- Installing kuria/iterable (v1.0.0): Downloading (100%)
- Installing acme/phpunit (7.5.8.0): Downloading (100%)
- Installing kuria/phpunit-extras (v2.0.3): Downloading (100%)
Writing lock file
Generating autoload files
```
5. add `"providers": true` to _satis.json_
6. build satis again
7. delete _composer.lock_ and _vendor_ in the test project
8. run `composer update`
This fails with the following:

```
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for kuria/phpunit-extras ^2.0.3 -> satisfiable by kuria/phpunit-extras[v2.0.3].
- kuria/phpunit-extras v2.0.3 requires phpunit/phpunit ^7.3.5 -> satisfiable by phpunit/phpunit[7.3.5, 7.4.0, 7.4.1, 7.4.2, 7.4.3, 7.4.4, 7.4.5, 7.5.0, 7.5.1, 7.5.2, 7.5.3, 7.5.4, 7.5.5, 7.5.6, 7.5.7, 7.5.8].
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.3.5
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.4.0
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.4.1
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.4.2
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.4.3
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.4.4
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.4.5
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.5.0
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.5.1
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.5.2
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.5.3
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.5.4
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.5.5
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.5.6
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.5.7
- don't install acme/phpunit 7.5.8.0|don't install phpunit/phpunit 7.5.8
- Installation request for acme/phpunit ^7.5 -> satisfiable by acme/phpunit[7.5.8.0]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.