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

Add opam tree subcommand to display a dependency tree #3775

Closed
g2p opened this issue Mar 9, 2019 · 7 comments · Fixed by #5171
Closed

Add opam tree subcommand to display a dependency tree #3775

g2p opened this issue Mar 9, 2019 · 7 comments · Fixed by #5171

Comments

@g2p
Copy link

g2p commented Mar 9, 2019

opam query only shows flat results.

opam tree, similar to cargo tree in Rust, would display a dependency tree. Here's how it looks like in Rust:

cargo tree
postgres v0.10.2 (file:///Volumes/git/rust/rust-postgres)
├── bufstream v0.1.1
├── byteorder v0.4.2
├── hex v0.1.0
├── log v0.3.4
│   └── libc v0.2.4
├── net2 v0.2.20
│   ├── cfg-if v0.1.0
│   ├── kernel32-sys v0.2.1
│   │   └── winapi v0.2.5
│   ├── libc v0.2.4 (*)
│   ├── winapi v0.2.5 (*)
│   └── ws2_32-sys v0.2.1
│       └── winapi v0.2.5 (*)
└── phf v0.7.9
    └── phf_shared v0.7.9

Note the Unicode-art.

Items marked with (*) are later instances of common subtrees; the subtrees are skipped instead of being printed another time.

Useful options:
--duplicate

This displays a forest of inverted trees, starting at every duplicate dependency, towards the root.
This is useful for examining how dependency versions get constrained.

@rjbou rjbou added this to To do in Feature Wish Jun 26, 2020
@cdaringe
Copy link

cdaringe commented Nov 1, 2020

i often have install deps that fail, and i want this feature to see who is calling for it. perhaps the parent node has bad ranges, needs to be pinned, etc.

@cdaringe
Copy link

cdaringe commented Nov 1, 2020

npm ls / yarn why are additional prior art that emit reduced graphs with the requested package as the leaf, and print up the dep tree to the root. super helpful

@vphantom
Copy link

vphantom commented Jan 26, 2022

Is there any way to get that kind of information, albeit not as nicely for now? I experimented with opam lock and I was surprised by some of the dependencies of my little project. I tried to track some down on https://opam.ocaml.org/packages/ but for some of them I'm stumped. (Like cppo, I'd expect as a build dependency but it's a normal dependency. No idea who needs it.)

(To clarify: I know that opam-query exists but it is incompatible with OCaml 4.08+ because of a dependency on an old version of containers. So I'm looking for other ways to get the information.)

@cannorin
Copy link
Contributor

I'm working on it and got this so far:
image

I'll open a PR once I complete docs and add adequate tests.

@avsm
Copy link
Member

avsm commented Jun 30, 2022

Your opam why output looks absolutely awesome. I want this in opam! :-)

@dbuenzli
Copy link
Contributor

@cannorin if you have some time to spend on this I'd suggest to look at this paper which seems to have interesting techniques for ASCII DAG visualisations.

@cannorin cannorin mentioned this issue Jul 1, 2022
5 tasks
@cannorin
Copy link
Contributor

cannorin commented Jul 1, 2022

@dbuenzli I've just read the paper. Looks interesting for sure, but it would need some additional work to allow annotating edges, which would be needed to show the constraints (e.g. (>= 4.0.0)). Also, we would need to try to make the graph as less wide as possible (since we are working with CLI), but the paper only mentions about it as a future work.

Feature Wish automation moved this from To do to Done Sep 12, 2022
@rjbou rjbou added this to the 2.2.0~alpha milestone Sep 12, 2022
@rjbou rjbou added this to To do in Opam 2.2.0 via automation Sep 12, 2022
@rjbou rjbou removed this from Done in Feature Wish Sep 12, 2022
@rjbou rjbou added this to To do in Feature Wish via automation Sep 12, 2022
@rjbou rjbou moved this from To do to Done in Feature Wish Sep 12, 2022
@rjbou rjbou moved this from To do to Done in Opam 2.2.0 Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Feature Wish
  
Done
Opam 2.2.0
  
Done
Development

Successfully merging a pull request may close this issue.

7 participants