Skip to content

[question] replace_tool_requires is confusing #4398

@timpatt

Description

@timpatt

What is your question?

When (host) conflicts arise with a "requires" requirement, we can use the "replace_requires" to fix them. Conflicts in "tool_requires" cannot be fixed using "replace_tool_requires", in the common case, though...

Some more detail:
I have a conanfile that has a dependency on Qt. In the particular version of the Qt recipe used, there is a conflict with libffi. To solve the conflict, I added the following to my host.profile file:

[replace_requires]
# Resolve conflict in qt 6.8.3 transitive dependencies between glib/2.85.3 (currently resolves to libffi/3.4.8) and wayland 1.22.0 (locked to libffi/3.4.4)
libffi/3.4.4: libffi/3.4.8

That solved the problem.

Now I add qt as a tool requires to my conanfile (this is contrived but required on the Windows build). Of course, the same conflict arose again, but this time in the build profile.

The first issue I had was that the error message didn't indicate that the build profile had the issue - I assumed it was the host profile and took me a while to work it out: "ERROR: Version conflict: Conflict between libffi/3.4.4 and libffi/3.4.8 in the graph. Conflict originates from wayland/1.22.0".

Following the pattern used in the host profile, the solution to the conflict should be obvious; add the following lines to my host.profile file:

[replace_tool_requires]
libffi/3.4.4: libffi/3.4.8

That seems reasonable to me, but it didn't work and was just ignored. I added the same lines to a "build.profile", but that didn't work either. What does work is to add replace_requires to the "build.profile". This makes sense, but I just spent the last 2 hours trying to work it out...

Repro:
conan lock create . -pr:h host.txt -pr:b build.txt

conanfile.py
host.txt
build.txt

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions