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] Compatible cached packages not resolved correctly #9880
Comments
As a first, quick feedback, I would like to comment that we are thinking about deprecating the We will have a look at this bug, thanks very much for your detailed report and investigation. |
Hi @memsharded and thank you for the quick response. We are currently using compatible_packages a lot with the use case of creating packages with multiple builds (debug and release) and providing compatible package ids for all of the involved build types. This is mostly due to us having a complete build system based on CMake and its config scripts, which requires having all build types within the packages for switching between these build types in the IDE. But some users of our packages apply the standard single build_type approach and we didn't want to create additional packages for those cases, so we use the compatible package feature. With your changes for Conan 2.0, do you think this approach ist still possible? |
Do you know that |
Thank you for the links and nice talk - good to see some hands on live footage :). We make heavy use of the workspace install feature with lots of dynamic libraries involved for use in the IDE until the point we are creating the packages. So far, the reason that kept us from using single builds for our packages was that CMake find_package does not support adding build type target scripts from different folders. And recreating all the CMake find info within the conanfile package_info for the conan imported targets is actually a problem with more complicated libraries (like Qt, ITK, VTK, etc), that's what we use the cmake config scripts for. But CMakeDeps is new to me. If this enables us to somehow use the standard config scripts for finding the dependencies and it will take care of handling build type specific target infos, this would be amazing. I will look into this, thank you very much! |
I am trying to reproduce this, this is the test I have so far: def test_compatible_diamond(self):
# https://github.com/conan-io/conan/issues/9880
client = TestClient()
conanfile = textwrap.dedent("""
from conan import ConanFile
class Pkg(ConanFile):
{}
settings = "build_type"
def package_id(self):
if self.settings.build_type == "Debug":
compatible_pkg = self.info.clone()
compatible_pkg.settings.build_type = "Release"
self.compatible_packages.append(compatible_pkg)
""")
client.save({"pkga/conanfile.py": conanfile.format(""),
"pkgb/conanfile.py": conanfile.format('requires = "pkga/0.1"'),
"pkgc/conanfile.py": conanfile.format('requires = "pkga/0.1"'),
"pkgd/conanfile.py": conanfile.format('requires = "pkgb/0.1", "pkgc/0.1"')
})
client.run("create pkga pkga/0.1@ -s build_type=Release")
client.run("create pkgb pkgb/0.1@ -s build_type=Release")
client.run("create pkgc pkgc/0.1@ -s build_type=Release")
client.run("install pkgd -s build_type=Debug")
print(client.out) Unfortunately, I don't see duplicated items in the |
Thanks for looking into this. I will try to reproduce the error with your test code and modify it accordingly. |
I guess the reason for multiple entries in the graph is that one package declares a requirement as private, while another package uses it as normal dependency. It can be reproduced with 3 packages, where pkga is used as private requirement by pkgb and both pkga and pkgb are requirements of pkgc. I've changed your code to the following test case:
But it turns out that this bug a rather tricky one, as its occurrence is non-deterministic and I wasn't able to reproduce it from the pytest call, at all. However, if I make the call to create pkgc from the command line, it will fail roughly 3 out of 10 times. I ran this with python 3.8 and conan 1.41.0 . This is the output in case it fails:
As you can see, pkga is listed twice as requirement and the correct package id is chosen initially, however while resolving the packages from cache, it skips the correct one. Hope this helps. |
Thanks very much for putting the effort to reproduce. Indeed using |
That is an impressive response time, thank you. I really need to dig into conan 2.0 . Just as a remark: we have ran our patched conan version with the "possible fix" I've mentioned in my initial post for quite some time now with also complex graph structures. We never had any issues with compatible packages so far. This is the change in the according method in the
|
Great, I have been able to reproduce with your test changes too. Also reviewed your fix, it is indeed looking good, exactly in the spot, great job. Thanks for all the work. I have submitted PR #10266 for 1.45, but if you want to submit it yourself to become official contributor, you totally deserve it, just let me know and I will close my PR. This will be naturally merged to |
I'm glad I was able to contribute something. I don't necessarily have to submit the PR, especially since you already did it, but thanks for the offer. |
Environment Details (include every applicable attribute)
Steps to reproduce (Include if Applicable)
If you call
conan install
on D with Settings2 we observer the following:A/1.0@user/channel: Main binary package 'f278b6f5a018dfdaf3f1aaf111c91b35b8dbeec5' missing. Using compatible package 'f85619e3f4a4d53fb5b48d3c40437fc2f08c69e6'
B/1.0@user/channel: Main binary package 'f278b6f5a018dfdaf3f1aaf111c91b35b8dbeec5' missing. Using compatible package 'f85619e3f4a4d53fb5b48d3c40437fc2f08c69e6'
C/1.0@user/channel: Main binary package 'f278b6f5a018dfdaf3f1aaf111c91b35b8dbeec5' missing. Using compatible package 'f85619e3f4a4d53fb5b48d3c40437fc2f08c69e6'
File "c:\programdata\anaconda3\lib\site-packages\conans\client\installer.py", line 560, in _handle_node_cache
assert os.path.isdir(package_folder), ("Package '%s' folder must exist: %s\n"
AssertionError: Package 'A/1.0@user/channel:f278b6f5a018dfdaf3f1aaf111c91b35b8dbeec5' folder must exist: C:\.conan\3785e5\1
Perhaps this might be related to #9446
Possible Fix ?
_evalute_node
from filegraph_binaries.py
is called and compatible packages are computed. Then, the _package_id of that node is set to the compatible package idf85619...
and the node.binary is set to cached mode._evaluate_is_cached
in the same file encounters the first node A (previous_nodes
) and sets its binary also cached as well. However, the _package_id is not modified.If we set the _package_id to the previous_node everything works fine but we are not sure if this has any unwanted side effects:
node._package_id = previous_node._package_id
I hope that this helps in resolving the bug.
The text was updated successfully, but these errors were encountered: