feat(pm): show require-by chain on dependency resolution failure#2804
Merged
feat(pm): show require-by chain on dependency resolution failure#2804
Conversation
When `ut install` fails to resolve a transitive dep, the error now includes the logical chain (root → ... → failing dep) so users can see which package pulled in the missing/broken dependency, rather than just the name of the failing package. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces logical dependency ancestry tracing to improve error reporting during package resolution. It adds a logical_ancestry method to the DependencyGraph to reconstruct the 'required by' chain and updates the ResolveError enum to include this chain, enabling a tree-like visualization of the dependency path in error messages. I have no feedback to provide.
Per review feedback — the tree-drawing belongs in the CLI layer (like ut list's `print_dep_tree` in cmd/list.rs), not in the library's error Display impl. - ruborist: `ResolveError::WithChain`'s Display now delegates to the wrapped source; the `chain` field is structured data only. - ruborist/api: preserve the typed error through anyhow via `Error::new + context` so downstream can downcast. - pm/util/format_print: new `format_resolve_chain` helper that scans the anyhow cause chain for `ResolveError::WithChain` and renders a tree with box characters. - pm/main: on error, prepend the decorated tree when present. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- build_requester_index: replace nested node/edge loops with a single pass over edge_references() and a let-chain filter. - logical_ancestry: replace the imperative walk (mutable current, visited, chain + multi-break while) with iter::successors + scan. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- build_requester_index: switch to early-continue (let-else) style so no statement sits deeper than the for-loop body. - logical_ancestry walker: replace if/else with Option::filter for a one-line predicate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fireairforce
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
ut installfails to resolve a transitive dep, the error previously showed only the failing package name — making it hard to find which of your declared dependencies pulled it in. This PR augmentsResolveErrorwith a dependency chain so the output now looks like:Design
DependencyGraph::logical_ancestry(node)walks the logical require-by chain (via resolvedDependencyEdge.to), not the physical install tree. With npm hoisting the physical tree is mostly flat under root, so a physical walk would hide the real introducers.O(N+E)scan is acceptable).ResolveError::WithChain { chain, source }variant, formatted in Display with a tree-style rendering that mirrorsut list.Test plan
cargo test -p utoo-ruborist— 160 tests pass, includestest_logical_ancestry_traces_hoisted_chain(sets up logicalroot→A→B→Cwith all three flat-hoisted physically, asserts the reported chain is[root, A, B, C]) andtest_with_chain_display_renders_treecargo clippy -p utoo-ruborist -p utoo-pm --all-targets -D warnings --no-deps— cleancargo fmt --check— clean🤖 Generated with Claude Code