-
Notifications
You must be signed in to change notification settings - Fork 377
Description
Describe the bug
Based on my understanding of the feature from the blog post and the documentation the [replace_requires]
section should replace requirements everywhere they show up in the dependency graph. However, it seems that if a package shows up transitively in the graph, replacement will cause the "parent" dependency to fail matching. Perhaps this is due to (from the documentation):
References listed under this section work as a literal replacement of requires in recipes, and is done as the very first step before any other processing of recipe requirements, without processing them or checking for conflicts.
This issue arises when trying to use [replace_requires]
to test a candidate version for an upstream dependency of a dependent pair:
project_a
├── project_b
└───┴ project_c
I've created a Minimal Working Example to demonstrate this issue. A summary of the MWE setup is:
package-a
exists at version 1.0package-b
exists at version 1.0 and depends onpackage-a/1.0
- Using a profile with
[replace-requires]
specifying a replacementpackage-a/1.0: package-a/1.1@dev/fix-a
,package-b/1.0
is no longer installable because it's requirements do not match
The error message in this case is:
ERROR: Missing binary: package-b/1.0:237a411982f9012227dd778400a9e4199de8c61e
package-b/1.0: WARN: Can't find a 'package-b/1.0' package binary '237a411982f9012227dd778400a9e4199de8c61e' for the configuration:
[settings]
arch=x86_64
os=Linux
[requires]
package-a/1.Y.Z@dev/fix-a
ERROR: Missing prebuilt package for 'package-b/1.0'. You can try:
- List all available packages using 'conan list "package-b/1.0:*" -r=remote'
- Explain missing binaries: replace 'conan install ...' with 'conan graph explain ...'
- Try to build locally from sources using the '--build=package-b/1.0' argument
More Info at 'https://docs.conan.io/2/knowledge/faq.html#error-missing-prebuilt-package'
How to reproduce it
For convenience I have attached this set of files as a single diff: conan-replace-requires-mwe.txt. The test setup can be recreated by the command:
patch -p1 < conan-replace-requires-mwe.txt
package-a/conanfile.py
:
from conan import ConanFile, conan_version
from conan.tools.files import copy
class PackageAConan(ConanFile):
name = "package-a"
settings = "os", "arch"
package-b/conanfile.py
:
from conan import ConanFile, conan_version
from conan.tools.files import copy
class PackageBConan(ConanFile):
name = "package-b"
settings = "os", "arch"
requires = "package-a/1.0"
host-profile.txt
: `
[settings]
os=Linux
arch=x86_64
[replace_requires]
package-a/1.0: package-a/1.1@dev/fix-a
repro.sh
:
conan create package-a --version 1.0
conan create package-a --version 1.1 --user dev --channel fix-a
conan create package-b --version 1.0
conan install --no-remote --requires "package-b/1.0"
conan install --no-remote --profile:host host-profile.txt --requires "package-b/1.0"