How do I show dependency tree for a cabal project
Asked Answered
C

2

9

I am using cabal v2-build to build a project and it keeps failing on a package that I do not directly depend on. Is there a way with cabal to list all of a package's dependencies (ideally in tree format) so I can see what I'm relying on that's calling the build fail and (hopefully) get rid of it.

Croatia answered 8/5, 2020 at 6:31 Comment(0)
A
8

Try cabal-plan: https://hackage.haskell.org/package/cabal-plan

In particular cabal-plan info will display copious information on dependencies in a tree format.

Note that cabal-plan requires that you've run cabal first, but the build need not complete successfully. It just needs to get past the build-plan stage. cabal-plan will then read the meta-info cabal created and display it in a readable format for you in detail.

(Aside: cabal-plan can also create transitive license info, quite useful as well. See the license-report option, which does require a separate flag during build time.)

Anjanetteanjela answered 8/5, 2020 at 7:7 Comment(1)
Indeed cabal-plan only needs that the cabal configure step executed successfully, creating the meta-info in the dist-newstyle directory.Psychoneurosis
P
3

cabal-plan does not seem to work for transitive dependencies.

You can use cabal freeze and look at the generated freeze file to see every single dependency that is required for the project.

(also, here's a useful tool for looking up reverse dependencies https://packdeps.haskellers.com/reverse)


cabal freeze writes out a freeze file which records all of the versions and flags that are picked by the solver under the current index and flags. Default name of this file is cabal.project.freeze
… …

https://cabal.readthedocs.io/en/3.8/cabal-commands.html#cabal-freeze

Palestine answered 13/8, 2022 at 19:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.