How to list all root dependencies in the current switch?

I thought I’d solved this with opam list --roots, but this only lists packages explicitly installed with opam install <package>. It does not include top-level dependencies installed from an .opam file with opam install . --deps-only. Is there any way for opam to list the roots including those installed from the .opam file?

It used to be in opam 2.1 but sadly this is a regression in opam 2.2.0. However this is fixed and merged in the 2.2 branch (ocaml/opam#6126) and will be released in opam 2.2.1 soon.

In the meantime, as long as the packages you want to list the dependencies of are pinned, you can list the root dependencies by using opam list --installed --required-by <pkgs> (where <pkgs> is to be replaced by a comma-separated list of the packages you want to list the dependencies of)

3 Likes