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

fix graph explain with no binaries #15823

Merged
merged 1 commit into from
Mar 6, 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
4 changes: 1 addition & 3 deletions conan/api/subapi/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def explain_missing_binaries(self, ref, conaninfo, remotes):
ConanOutput().info(f"Finding binaries in remote {remote.name}")
pkg_configurations = self.packages_configurations(ref, remote=remote)
except Exception as e:
pass
ConanOutput(f"ERROR IN REMOTE {remote.name}: {e}")
else:
candidates.extend(_BinaryDistance(pref, data, conaninfo, remote)
Expand All @@ -232,8 +231,7 @@ def explain_missing_binaries(self, ref, conaninfo, remotes):
candidates.sort()
pkglist = PackagesList()
pkglist.add_refs([ref])
# If there are exact matches, only return the matches
# else, limit to the number specified
# Return the closest matches, stop adding when distance is increased
candidate_distance = None
for candidate in candidates:
if candidate_distance and candidate.distance != candidate_distance:
Expand Down
5 changes: 5 additions & 0 deletions conan/cli/commands/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def explain_formatter_text(data):
# we need to wrap this in a MultiPackagesList
pkglist = data["closest_binaries"]
prepare_pkglist_compact(pkglist)
# Now we make sure that if there are no binaries we will print something that makes sense
for ref, ref_info in pkglist.items():
for rrev, rrev_info in ref_info.items():
if not rrev_info:
rrev_info["ERROR"] = "No package binaries exist"
print_serial(pkglist)


Expand Down
10 changes: 10 additions & 0 deletions conans/test/integration/command_v2/test_graph_find_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,13 @@ def test_multiple_distance_ordering(self):
assert "a657a8fc96dd855e2a1c90a9fe80125f0c4635a0" not in tc.out
# We expect the closer binary to show
assert "a6923b987deb1469815dda84aab36ac34f370c48" in tc.out


def test_no_binaries():
# https://github.com/conan-io/conan/issues/15819
c = TestClient()
c.save({"conanfile.py": GenConanfile("pkg", "0.1")})
c.run("export .")
c.run("graph explain --requires=pkg/0.1")
assert "ERROR: No package binaries exist" in c.out
# The json is not an issue, it won't have anything as contents