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

[question] How to properly use replace_requires? #16399

Closed
1 task done
Nekto89 opened this issue Jun 4, 2024 · 7 comments · Fixed by #16443
Closed
1 task done

[question] How to properly use replace_requires? #16399

Nekto89 opened this issue Jun 4, 2024 · 7 comments · Fixed by #16443
Assignees
Milestone

Comments

@Nekto89
Copy link
Contributor

Nekto89 commented Jun 4, 2024

What is your question?

Hi, I have a question regarding replace_requires.

Previously I was changing recipes to be able to use zlib-ng instead of zlib. [replace_requires] should be able to allow me to do this without change of recipes if I understood correctly. But I can't make it work. Is this a problem of recipe that uses zlib, recipe of zlib-ng or conan? Or maybe I'm doing something completely wrong?

conan install -r=conancenter "--requires=crowcpp-crow/1.2.0" -pr:b build_profile -pr:h host_profile --build=missing

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.update=9
compiler.version=192
os=Windows
[options]
crowcpp-crow/*:with_compression=True
crowcpp-crow/*:with_ssl=False
zlib-ng/*:zlib_compat=True
[conf]
tools.cmake.cmaketoolchain:generator=Visual Studio 17 2022

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.update=9
compiler.version=192
os=Windows
[conf]



======== Computing dependency graph ========
Graph root
    cli
Requirements
    asio/1.29.0#52d17a857aa6f978d8c17d7c38eae5ad - Cache
    crowcpp-crow/1.2.0#144d39a4f1ee5436ecfa06ccd5c547f4 - Cache
    zlib-ng/2.1.6#9e56e2ad03e40e7d0b3d22a2274fb37c - Cache
Replaced requires
    zlib/[>=1.2.11 <2]: zlib-ng/2.1.6

======== Computing necessary packages ========
Requirements
    asio/1.29.0#52d17a857aa6f978d8c17d7c38eae5ad:da39a3ee5e6b4b0d3255bfef95601890afd80709#b132a176c32962cb7be826d56fbe242d - Cache
    crowcpp-crow/1.2.0#144d39a4f1ee5436ecfa06ccd5c547f4:208bab9127ec1e26e476b4f3fdeccd1dbc047790#b970240236456bdd009782b4c1bd14e7 - Cache
    zlib-ng/2.1.6#9e56e2ad03e40e7d0b3d22a2274fb37c:a813a49d371fc5b0c1ac8bad0b668beb010b8773#75dbedba30941d7b350f3bfa45517079 - Cache

======== Installing packages ========
asio/1.29.0: Already installed! (1 of 3)
zlib-ng/2.1.6: Already installed! (2 of 3)
crowcpp-crow/1.2.0: Already installed! (3 of 3)
ERROR: crowcpp-crow/1.2.0: required component package 'zlib::' not in dependencies

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@AbrilRBS AbrilRBS self-assigned this Jun 4, 2024
@Nekto89
Copy link
Contributor Author

Nekto89 commented Jun 4, 2024

I just noticed that conan doesn't output replace_requires in log. It is present in my host profile

[replace_requires]
zlib/* : zlib-ng/2.1.6

@AbrilRBS
Copy link
Member

AbrilRBS commented Jun 4, 2024

Hi @Nekto89 thanks a lot for taking the time to report the issue.

While it's true that this is one great side-effect of the feature, this aspect is not fully realized yet, so some shortcomings are still expected. We are planning on thinking more about this issue to provide solutions for this usage (And it's one of the reasons for which we've stop accepting PRs in CCI that add a with_zlibng option to recipes, the idea is to let users choose via the replace mechanism)

I'll let you know once we have some solid ground to work on, but for now I'll check if there's something to be done in the recipe to support this use-case without too many modifications :)

@AbrilRBS
Copy link
Member

AbrilRBS commented Jun 4, 2024

I just noticed that conan doesn't output replace_requires in log. It is present in my host profile [replace_requires] zlib/* : zlib-ng/2.1.6

I'm proposing #16401 for Conan 2.4 next release to fix this issue, thanks for the heads-up :)

@memsharded memsharded added this to the 2.5.0 milestone Jun 5, 2024
@jan-guenter
Copy link

I'm also trying to use replace_requires to substitute zlib-ng for zlib. The main issue I'm facing is that many recipes like openssl use self.dependencies["zlib"] which then fails with KeyError: "'zlib' not found in the dependency set"

Perhaps a bit naïve, but wouldn't it make sense to alias the dependencies with their original name in the dependencies dict?

@memsharded
Copy link
Member

I am investigating in #16443 if it is possible to allow this, or replace_requires requires full referential transparency. Even with this investigation can improve things a bit on the Conan side, there might be other aspects like CMakeLists.txt with a find_package(ZLIB) will hardly work unless the replacement zlib-ng is configured to create the same ZLIB-Config.cmake filename and possible target names.

@memsharded
Copy link
Member

memsharded commented Jun 21, 2024

@AbrilRBS has also been investigating the part of the cpp_info.requires, we are doing progress, but still need more research.

@memsharded memsharded modified the milestones: 2.5.0, 2.6.0 Jun 21, 2024
@memsharded memsharded modified the milestones: 2.6.0, 2.7.0 Jul 31, 2024
@memsharded memsharded modified the milestones: 2.7.0, 2.8.0 Aug 27, 2024
@memsharded
Copy link
Member

#16443 has been merged, it will be in next 2.8 release.

It should cover the cases of referential transparency for self.dependencies[<depname>] and cpp_info.requires checks. For CMake targets and similar stuff, either the replacement provides transparent replacement, or it will not be possible to manage them with [replace_requires] as the docs say, there are limits, it is only for replacements designed to be transparent replacements.

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

Successfully merging a pull request may close this issue.

4 participants