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

lockfile error msg #16841

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions conans/model/graph_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,15 @@ def serialize(self):
def resolve_locked(self, node, require, resolve_prereleases):
if require.build or node.context == CONTEXT_BUILD:
locked_refs = self._build_requires.refs()
kind = "build_requires"
elif node.is_conf:
locked_refs = self._conf_requires.refs()
kind = "config_requires"
else:
locked_refs = self._requires.refs()
kind = "requires"
try:
self._resolve(require, locked_refs, resolve_prereleases)
self._resolve(require, locked_refs, resolve_prereleases, kind)
except ConanException:
overrides = self._overrides.get(require.ref)
if overrides is not None and len(overrides) > 1:
Expand Down Expand Up @@ -315,7 +318,7 @@ def resolve_prev(self, node):
if prevs:
return prevs.get(node.package_id)

def _resolve(self, require, locked_refs, resolve_prereleases):
def _resolve(self, require, locked_refs, resolve_prereleases, kind):
version_range = require.version_range
ref = require.ref
matches = [r for r in locked_refs if r.name == ref.name and r.user == ref.user and
Expand All @@ -327,7 +330,7 @@ def _resolve(self, require, locked_refs, resolve_prereleases):
break
else:
if not self.partial:
raise ConanException(f"Requirement '{ref}' not in lockfile")
raise ConanException(f"Requirement '{ref}' not in lockfile '{kind}'")
else:
ref = require.ref
if ref.revision is None:
Expand All @@ -337,10 +340,10 @@ def _resolve(self, require, locked_refs, resolve_prereleases):
break
else:
if not self.partial:
raise ConanException(f"Requirement '{ref}' not in lockfile")
raise ConanException(f"Requirement '{ref}' not in lockfile '{kind}'")
else:
if ref not in matches and not self.partial:
raise ConanException(f"Requirement '{repr(ref)}' not in lockfile")
raise ConanException(f"Requirement '{repr(ref)}' not in lockfile '{kind}'")

def replace_alias(self, require, alias):
locked_alias = self._alias.get(alias)
Expand All @@ -352,4 +355,4 @@ def replace_alias(self, require, alias):

def resolve_locked_pyrequires(self, require, resolve_prereleases=None):
locked_refs = self._python_requires.refs() # CHANGE
self._resolve(require, locked_refs, resolve_prereleases)
self._resolve(require, locked_refs, resolve_prereleases, "python_requires")
3 changes: 2 additions & 1 deletion test/integration/lockfile/test_lock_requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def test_conanfile_txt_strict(requires):
client.save({"consumer/conanfile.txt": f"[{requires}]\npkg/[>1.0]@user/testing"})

client.run("install consumer/conanfile.txt", assert_error=True)
assert "Requirement 'pkg/[>1.0]@user/testing' not in lockfile" in client.out
kind = "build_requires" if requires == "tool_requires" else "requires"
assert f"Requirement 'pkg/[>1.0]@user/testing' not in lockfile '{kind}'" in client.out

client.run("install consumer/conanfile.txt --lockfile-partial")
assert "pkg/1.2@user/testing" in client.out
Expand Down