conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.3k stars 986 forks source link

[bug] Conflict between profile tool_require and recipe require #16977

Open jjcasmar opened 2 months ago

jjcasmar commented 2 months ago

Describe the bug

When using a profile with a tool_requires, I am getting a conflict between some dependency of the tool and a dependency of the recipe

conan install command

 conan install . --profile:build=conan/profiles/x86_64-gcc-10 --profile:host=conan/profiles/wasm-clang-16 --settings:host="*:build_type=Release" --settings:host="&:build_type=Debug" --build="*"

throws

ERROR: Version conflict: Conflict between nodejs/20.16.0 and nodejs/16.3.0 in the graph.
Conflict originates from boost/1.82.0

According to discussion in Slack channel, the dependency in the profile should override others, but in this case still fails.

conanfile.py

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.env import VirtualRunEnv

required_conan_version = ">=1.59"

class ProfileConflictConan(ConanFile):
    name = "profile_conflict"

    # Binary configuration
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False], "fPIC": [True, False]}
    default_options = {"shared": False, "fPIC": True}

    def requirements(self):
        self.requires("boost/1.82.0")

    def config_options(self):
        if self.options.shared:
            del self.options.fPIC

        if self.settings.os == "Emscripten":
            self.options["boost"].header_only = True 

    def layout(self):
        cmake_layout(self)

    def generate(self):
        cmake = CMakeDeps(self)
        cmake.generate()

        toolchain = CMakeToolchain(self)
        toolchain.generate()

x86_64-gcc-10 profile

[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=10
compiler.libcxx=libstdc++11
build_type=Release

[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.cmake.cmake_layout:build_folder_vars=['settings.arch', 'settings.compiler', 'settings.compiler.version']

wasm-clang-16 profile

[settings]
os=Emscripten
arch=wasm
compiler=clang
compiler.version=16
build_type=Release

[tool_requires]
emsdk/3.1.50
nodejs/20.16.0

How to reproduce it

No response

memsharded commented 2 months ago

Hi @jjcasmar

Thanks for your report and the details to reproduce.

@AbrilRBS has been investigating this, it is possible that there is some unexpected relationship in the nodejs and emsdk that is making this generate the conflict. So the conflict is not solved by the profile tool-requires because it seems it is originated by the tool-requires themselves.

We will check first the recipes from ConanCenter to see if it can be fixed there. I think we can keep the ticket here until it is confirmed it can be changed in recipes.

memsharded commented 3 hours ago

Sorry we didn't manage to follow up on this. I can confirm that this is still happening, a bit simpler repro:

conan install --requires=zlib/1.3.1 --profile:host=profile --settings:host="*:build_type=Release" --settings:host="&:build_type=Debug"
...
ERROR: Version conflict: Conflict between nodejs/20.16.0 and nodejs/16.3.0 in the graph.
Conflict originates from zlib/1.3.1
memsharded commented 3 hours ago

Also, to clarify, this doesn't seem a bug in the Conan client, but some misalignment of versions. If I do:

conan install --tool-requires=nodejs/16.3.0 --tool-requires=emsdk/3.1.50

It works, but:

conan install --tool-requires=nodejs/20.16.0 --tool-requires=emsdk/3.1.50
...
ERROR: Runtime Error: Could not process 'emsdk/3.1.50' with 'nodejs/16.3.0'

So mostly is that those versions are not designed to work well together. It needs to be investigated if this can be improved, but still seems something related to the specific Conan recipes from ConanCenter, not the Conan client.