Skip to content

Conversation

@andrey-zherikov
Copy link

Changelog: Bugfix: Fix for depending on all components of [replace_requires] package
Docs: https://github.com/conan-io/docs/pull/XXXX

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

@AbrilRBS IDK how dirty or acceptable this change is but it fixes #18986

@CLAassistant
Copy link

CLAassistant commented Sep 25, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @andrey-zherikov

Thanks for your contribution.
However, we already considered doing this, and we didn't proceed to update CMakeDeps to support this because there is a risk of breaking other users, this is why it was only done in CMakeConfigDeps

We will have a look and consider it, but it is likely that it won't be moved forward.

@memsharded
Copy link
Member

As you can see, this change has broken some existing tests: https://github.com/conan-io/conan/actions/runs/17994704568?pr=18987

This is why this kind of change is very risky for CMakeDeps

@andrey-zherikov
Copy link
Author

As you can see, this change has broken some existing tests: https://github.com/conan-io/conan/actions/runs/17994704568?pr=18987

This is why this kind of change is very risky for CMakeDeps

I see only one test failure:

FAILED test/integration/graph/test_replace_requires.py::test_replace_requires_consumer_references[zlib-ng-0.1] - Failed: /__w/conan/conan/test/integration/graph/test_replace_requires.py:219
==================== Command succeeded (failure expected): =====================
install --requires=app/0.1 -pr=profile -g CMakeDeps

This should be expected to pass with the change so assert_error=True should be removed

@memsharded
Copy link
Member

Many thanks for checking it.

Still, we evaluated that, and while it seems that such code might fix one case, it is certainly quite risky and could break other cases, even if they are not captured by the tests, the usage of CMakeDeps is too large, and it is very likely that there will be usages of certain patterns of components that will be affected by this change.

It seems the assert_error=True is there to ensure that CMakeDeps does not try to address this, like this check was added explicitly to assert that CMakeDeps will not be supporting this use case.

This is also why we are pushing for CMakeConfigDeps feedback, testing by users, etc., it is the natural replacement for CMakeDeps that happened because important changes and features couldn't be done to it without a high risk of breaking users. And support for [replace_requires] was already evaluated and done only to CMakeConfigDeps for this reason too.

@andrey-zherikov
Copy link
Author

@memsharded thanks for taking a look. As I noted in the linked issue, CMakeConfigDeps doesn't work for openssl recipe from the conan-center-index, so we won't be able to use it even if it goes out of incubation.

@andrey-zherikov
Copy link
Author

@memsharded I might be wrong for sure because you know conan source code and usage much better than me, but my thoughts were:

  1. The problem is when we depend on all components, ie. A::A, so the fix should affect only the case when <pkg> == <comp> in <pkg>::<comp>.
  2. AFAIU, req in get_deps_targets_names and in _get_required_components_cpp contains resolved package reference with replace_requires applied.
  3. My change checks whether it's a "dependency on all components" (1) and if so, then translates it to "dependency on all components" of a resolved dependency (2).

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

Successfully merging this pull request may close these issues.

[bug] replace_requires doesn't work with cpp_info.components[...].requires

3 participants