Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Deployer cannot deploy transitive dependencies of build_requires #17433

Open
SzBosch opened this issue Dec 9, 2024 · 3 comments
Open
Assignees

Comments

@SzBosch
Copy link
Contributor

SzBosch commented Dec 9, 2024

Describe the bug

Tested with Conan 2.0.16 and 2.10.1.

Given the following dependency structure:

myprj -> build_require(pkgA) -> require(pkgB)

The deployer shall deploy both pkgA and pkgB. To be able to do this a copy() is necessary accessing the "package_folder" attribute (pointing to the location in the cache"). This is not working, because for pkgB the value of "package_folder" is "None".

How to reproduce it

This can be demonstrated by the following deployer code:

def deploy(graph, output_folder, **_kwargs):
    for require, dep in graph.root.conanfile.dependencies.items():
        print(f"{dep}: {dep.package_folder}")
        for sub_require, sub_dep in dep.dependencies.items():
            print(f"{sub_dep}: {sub_dep.package_folder}")

The output is then like:

pkgA/1.0.0: <conan-home>\.conan2\p\<proper-location>
pkgB/1.0.0: None

Expected:

pkgA/1.0.0: <conan-home>\.conan2\p\<proper-location>
pkgB/1.0.0: <conan-home>\.conan2\p\<proper-location>
@AbrilRBS AbrilRBS self-assigned this Dec 9, 2024
@AbrilRBS
Copy link
Member

AbrilRBS commented Dec 9, 2024

Hi @SzBosch thanks for your report.

This would probably not be a bug, but expected behaviour. Conan might be skipping pkgB as not needed in the current graph, as it's only needed for pkgA.

As per https://docs.conan.io/2/examples/extensions/deployers/sources/custom_deployer_sources.html#deploy, you might be looking into running your deploy with -c:a="tools.graph:skip_binaries=False", which will ensure that no package is skipped

Let me know if this helps :)

@SzBosch
Copy link
Contributor Author

SzBosch commented Dec 9, 2024

Hello @AbrilRBS , thank you for your answer I will test your suggestion.

To give you a little more context:
I changed the structure from

myprj -> require(pkgA) -> require(pkgB)

to

myprj -> build_require(pkgA) -> require(pkgB)

because with normal require of pkgA the pkgB cannot be in the graph multiple times with different versions.
Please see my comment here: #2601 (comment)
Maybe there is a kind of bug?

So we need at the end a possibility to have both at the same time:

  1. having pkgB multiple times as transitive dependency in the graph with different versions
  2. deploying all packages in the graph with a custom deployer

@AbrilRBS
Copy link
Member

AbrilRBS commented Dec 9, 2024

No, this case would not be a bug either

because with normal require of pkgA the pkgB cannot be in the graph multiple times with different versions.

Please note that as per our documentation https://docs.conan.io/2/reference/conanfile/methods/build_requirements.html#tool-requires, tool requires are intended exclusively for depending on tools like cmake or ninja, which run in the “build” context, so your use-case is an anti-pattern and highly discouraged

A better approach for your case might be using the visible=False trait in the pkgA -> `kgB requirement, documented here, but cases where this is a valid solution that does not produce ODR violations are far and few between, so some consideration is also needed for that case

That solves your first point, and remember the second one is solved with the conf from my previous comment, so please try them and let us know if it works, happy to help where needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants