-
Notifications
You must be signed in to change notification settings - Fork 988
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] Regression from v2.7.1: "Required package 'nlohmann_json' not in component 'requires'" #17164
Comments
I really don't know. I've been trying to create the minimal reproducer for last couple of ours, and so far it has 6 packages with interconnections that resemble my real project but it doesn't reproduce the issue. However, the real project with 300+ nodes in the dependency graph, reproduces it. Can I somehow provide you with graph data from my real project that may have any meaning to you for debugging? |
I have done a full diff between 2.8 and 2.7.1 and I cannot find anything that would be modifying something regarding the
The first step would be to compare the result of Then, I think the best would be to instrument a bit the Conan code, run in 2.7.1 and 2.8.0 and compare. First, lets try to report the direct dependencies in diff --git a/conans/model/build_info.py b/conans/model/build_info.py
index 4505075e6..ec7e99d46 100644
--- a/conans/model/build_info.py
+++ b/conans/model/build_info.py
@@ -653,7 +653,8 @@ class CppInfo:
# So consumers can keep their ``self.cpp_info.requires = ["pkg_name::comp"]``
direct_dependencies = [r.ref.name for r, d in conanfile.dependencies.items() if r.direct
and not r.build and not r.is_test and r.visible and not r.override]
-
+ conanfile.output.info(f"Checking component requires")
+ conanfile.output.info(f"DIRECT DEPENDENCIES: {direct_dependencies}")
for e in external:
if e not in direct_dependencies:
raise ConanException( |
I've added the log from your diff to both v2.7.1 and v2.8.0 installations I have on my machines and ran The terminal outputs are attached. In the diff I see that v2.8.0 thinks that |
Ok, yes, can you please share the dependency graphs in json with |
Sure. Diff on those two files is empty, meaning that both v2.7.1 and v2.8.0 generated the same graph 🤔 |
That is quite unexpected. Maybe the |
Sure: from os.path import join
from conan import ConanFile
from conan.tools.files import copy
class DocumentVerificationRecognizerPackageTest(ConanFile):
python_requires = 'conanfile_utils/[~1]@microblink/main'
python_requires_extend = 'conanfile_utils.MicroblinkConanFile'
def requirements(self):
self.requires(self.tested_reference_str)
self.requires('keygen/[~12]@microblink/main')
self.requires('version_and_paths/[~1]@microblink/main')
def generate(self):
# Copy all resource files from all dependencies to the `res`directory
for dep in self.dependencies.values():
if len(dep.cpp_info.resdirs) == 1:
copy(self, "*", src=dep.cpp_info.resdirs[0], dst=join(self.build_folder, 'res'), keep_path=False)
copy(self, "features_*", dep.package_folder, join(self.build_folder, 'features_cmake'))
# Run the base class `generate` method
super().generate()
def test(self):
self.mb_run_test('DocumentVerificationRecognizerPackageTest') Neither |
Can you please simplify that |
Even a barebones That's really weird. |
So what does a |
🤔 , the error is thrown even when creating a package with |
I saw in the graph.json information that you reported that the "root" node contains: "181": {
"ref": "nlohmann_json/3.10.4",
"run": false,
"libs": true,
"skip": false,
"test": false,
"force": false,
"direct": true,
"build": false,
"transitive_headers": true,
"transitive_libs": null,
"headers": true,
"package_id_mode": "minor_mode",
"visible": true
}, As a dependency. According to this, the This took me to a possible change in 2.8, related to the |
That's also my hunch, although I couldn't reproduce the issue with smaller example. The Theoretically, if I remove However, that change would not be correct long-terms because I'm not using the |
Can you please double check that the above I have been able to reproduce it with: def requirements(self):
self.test_requires("liba/1.0")
self.requires("libb/1.0") That is, declaring the |
According to the documentation, But, as a matter of fact, our def requirements(self):
self.requires('blinkid_generic_recognizer/[~10]@microblink/main', transitive_headers=True)
self.requires('ml_models_document_verification/[~4]@microblink/main')
self.requires('ml_models_image_capture/[~3]@microblink/main')
self.requires('ml_image_capture/[~1]@microblink/main')
if not self.is_cross_compiling:
# VA request
self.requires('cpr/[~1]@microblink/main')
self.requires('model_protection/[~2]@microblink/main')
# Model Proxy
self.requires('mlp_model_proxy/[~0]@microblink/main')
def build_requirements(self):
if not self.is_cross_compiling:
self.test_requires('crow/[~1]@microblink/main')
self.test_requires('nlohmann_json/3.10.4')
self.test_requires('mls_testing/[~9]@microblink/main')
self.test_requires('keygen/[~12]@microblink/main')
self.tool_requires('compress_utility/[~1]@microblink/main') |
I think I might have a fix, I am running some tests. diff --git a/conans/model/requires.py b/conans/model/requires.py
index d9a9dbc76..cb819d74e 100644
--- a/conans/model/requires.py
+++ b/conans/model/requires.py
@@ -254,6 +254,7 @@ class Requirement:
self.transitive_libs = self.transitive_libs or other.transitive_libs
if not other.test:
self.test = False # it it was previously a test, but also required by non-test
+ self.is_test = self.is_test or other.is_test
# package_id_mode is not being propagated downstream. So it is enough to check if the
# current require already defined it or not
if self.package_id_mode is None:
@@ -344,6 +345,7 @@ class Requirement:
if self.test:
downstream_require.test = True
+ downstream_require.is_test = require.is_test
# If the current one is resolving conflicts, the downstream one will be too
downstream_require.force = require.force If this is confirmed, we will release a 2.8.1 soon. |
I confirm this patch works on my project. Thank you for the fix. |
Closed by #17174 for next Conan 2.8.1 |
Describe the bug
I have a package that test-depends on
nhlohmann_json
:When creating the package with conan v2.8.0, I get the error
Required package 'nlohmann_json' not in component 'requires'
after package gets built andtest_package
is executed to test the packaging.As you can see,
nlohmann_json
is just a test dependency, so it doesn't need to be listed inself.cpp_info.requires
.Downgrading to v2.7.1 helps fixing the issue (v2.7.1 correctly builds and tests the package).
How to reproduce it
No response
The text was updated successfully, but these errors were encountered: