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

Improve graph conflict message when Conan can't show one of the conflicting recipes #13946

Merged
merged 8 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 13 additions & 3 deletions conans/client/graph/graph_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ def __init__(self, node, require, prev_node, prev_require, base_previous):
self.base_previous = base_previous

def __str__(self):
return f"Version conflict: {self.node.ref}->{self.require.ref}, "\
f"{self.base_previous.ref}->{self.prev_require.ref}."
if self.node.ref is not None and self.base_previous.ref is not None:
return f"Version conflict: {self.node.ref}->{self.require.ref}, " \
f"{self.base_previous.ref}->{self.prev_require.ref}."
else:
conflicting_node = self.node.ref or self.base_previous.ref
conflicting_node_msg = ""
if conflicting_node is not None:
conflicting_node_msg = f"\nConflict originates from {conflicting_node}\n"
return f"Version conflict: " \
f"Conflict between {self.require.ref} and {self.prev_require.ref} in the graph." \
f"{conflicting_node_msg}" \
f"\nRun conan graph info ... --format=html to inspect the graph errors."
Copy link
Member

Choose a reason for hiding this comment

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

I would print this --format=html (with redirect > graph.html) in all cases, even the "simple" part of the if

Copy link
Contributor

Choose a reason for hiding this comment

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

can it print actual arguments here instead of ...? so it could be copy-pasted easily.



class GraphLoopError(GraphError):
Expand All @@ -27,7 +37,7 @@ def __init__(self, node, require, ancestor):
self.ancestor = ancestor

def __str__(self):
return "There is a cycle/loop in the graph:\n"\
return "There is a cycle/loop in the graph:\n" \
f" Initial ancestor: {self.ancestor}\n" \
f" Require: {self.require.ref}\n" \
f" Dependency: {self.node}"
Expand Down
4 changes: 4 additions & 0 deletions conans/test/integration/graph/conflict_diamond_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ def _game_conanfile(version, reverse=False):
c.assert_overrides({"math/1.0": [f"math/{v}"],
"math/1.0.1": [f"math/{v}#8e1a7a5ce869d8c54ae3d33468fd657c"]})
c.assert_listed_require({f"math/{v}": "Cache"})

c.run("install --requires=engine/1.0 --requires=ai/1.0", assert_error=True)
assert "Conflict between math/1.0.1 and math/1.0 in the graph"
assert "Conflict originates from ai/1.0"
Copy link
Member

Choose a reason for hiding this comment

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

Check that --format=html is also suggested