conan-io / conan

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

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

Open jjcasmar opened 1 month ago

jjcasmar commented 1 month 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 1 month 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.